[mercury-users] First solution in csharp without try/catch

Paul Bone pbone at csse.unimelb.edu.au
Tue Jan 17 14:14:20 AEDT 2012


On Sat, Jan 14, 2012 at 09:03:08AM -0800, Jeff Thompson wrote:
> 
> As above, the times for Mercury code are 0.45 seconds for the
> baseline and 171 seconds if it commits.  For the "yield" code it is
> 2.33 seconds for the baseline and 2.03 if it commits after one
> solution.  As expected, since the "yield" code uses the same
> infrastructure in both cases, it takes less time to search less
> solutions.  But the baseline Mercury code is faster than the "yield"
> code which allocates an iterator object on the heap for every
> "foreach" loop (as opposed to Mercury's more efficient approach of
> using continuations).
> 
> 
> 	X > 2 	X > 0
> Mercury 11.07 	0.45 	171
> "yield" 	2.33 	2.03
> 

What you have to consider is how often you commit to the first solution and how
often you have a nondet search that does not commit to the first solution (or
that takes a _long_ time to find the first solution).

Because commit happens once you only have to pay for try/catch once, but when
using yield we have to pay for it often (once per node in the search tree).  In
a nontrivial example this cost will dominate.  Meanwhile, as the size of the
search space grows the importance of the one-time cost of try/catch will become
less and less important.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/users/attachments/20120117/d36d94e9/attachment.sig>


More information about the users mailing list