[mercury-users] First solution in csharp without try/catch
Paul Bone
pbone at csse.unimelb.edu.au
Tue Jan 17 14:20:32 AEDT 2012
On Tue, Jan 17, 2012 at 02:14:20PM +1100, Paul Bone wrote:
> 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.
>
Additionally, if your search is so simple (such as the examples you've used);
then try/catch will be the dominant cost. However, unless you're doing 10,000
searches in quick succession you won't notice.
-------------- 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/d38fe207/attachment.sig>
More information about the users
mailing list