Subject: [UFL-dev] Alternative faster assertion method

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 4 Feb 2009 10:42:12 +0100

I won't change the code everywhere to do this now,
but if profiling in the future shows all the ufl_assert
calls to take significant time, we can do this:

  isinstance(a, Expr) or error("Expecting Expr instance.")

instead of this:

  ufl_assert(isinstance(a, Expr), "Expecting Expr instance.")

They do exactly the same, the length is about the same,
but the former is much cheaper as long as it doesn't trigger.

Martin

---

From: Johan Hake <[email-masked]>
Date: Wed, 4 Feb 2009 14:12:35 +0100

> but the former is much cheaper as long as it doesn't trigger.

Some annoying questions ;)

How much is much and how does this compare to all other things you are doing?

Johan

> Martin
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 4 Feb 2009 14:15:16 +0100

> How much is much and how does this compare to all other things you are doing?

1) I haven't measured, but function calls are expensive and with the
ufl_assert approach the function is entered every time.

2) Don't know, which is why I wrote "if profiling ..."

Martin

---

From: Johan Hake <[email-masked]>
Date: Wed, 4 Feb 2009 14:24:15 +0100

> 2) Don't know, which is why I wrote "if profiling ..."

Ok :)

Johan

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 4 Feb 2009 14:31:28 +0100

>> 2) Don't know, which is why I wrote "if profiling ..."

About a factor 4 in a simplified case.
The reason we may want to optimize this is
that almost every operation does assertions.

Martin