Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENHANCED: time/1 now shows the number of inferences #1999

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

triska
Copy link
Contributor

@triska triska commented Sep 5, 2023

I'm marking this as a draft because it does not yet show the number of inferences when the goal fails.

@triska
Copy link
Contributor Author

triska commented Sep 5, 2023

In addition, nested time/1 calls do not yet work with these changes:

:- time(use_module(library(lists))).
   % 0.000s CPU, 20 inferences
?- time(time(member(X, "abc"))).
   % 0.000s CPU, 2 inferences
   % 0.000s CPU, 2_202 inferences
   X = a
;  % 0.000s CPU
   error(representation_error(inference_limit),time/1), unexpected.

Update: Nested calls are now addressed.

@triska
Copy link
Contributor Author

triska commented Sep 10, 2023

Please see #2009 for the issues I encountered with the current approach. I think a separate internal inference counter is needed.

@mthom mthom force-pushed the master branch 7 times, most recently from 0666b56 to dff2e73 Compare October 15, 2023 23:43
@infogulch infogulch mentioned this pull request Nov 8, 2023
@mthom
Copy link
Owner

mthom commented Nov 20, 2023

I updated my copy of this PR branch with changes at https://github.com/mthom/scryer-prolog/tree/triska-time_inferences, please try it and give feedback.

@triska triska marked this pull request as ready for review November 21, 2023 19:27
@triska
Copy link
Contributor Author

triska commented Nov 21, 2023

I have updated the branch, using the newly available inference counting feature.

Some fine-tuning may be appropriate for specific cases such as ?- time(false)., though it is not clear to me where this tuning should happen: in the internal inference counting mechanism, or in library(time).

Please review, and merge if applicable. Thank you a lot!

Example:

    ?- time(member(X, "abc")).
       % CPU time: 0.000s, 1 inference
       X = a
    ;  % CPU time: 0.000s, 3 inferences
       X = b
    ;  % CPU time: 0.000s, 3 inferences
       X = c.

This is an initial step towards addressing mthom#1039.
@mthom mthom merged commit 041ec06 into mthom:master Nov 21, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants