# Time results understanding

Hey,
I used the time predicate to measure my program.
I have implemented my program in 2 various way:

1. First algorithm time result:
``````% 3,325,335 inferences, 1.344 CPU in 30.602 seconds (4% CPU, 2474668 Lips)
``````
1. Second algorithm time result:
``````% 925,746 inferences, 0.156 CPU in 0.168 seconds (93% CPU, 5924774 Lips)
``````

What those parameter means? (inferences, lips)
The second one is more quicker, but it takes more CPU in %.
What is better, besides the time it takes.

Westly

â€śLipsâ€ť is â€śLogical inferences per secondâ€ť.

It comes from an old benchmark of â€śnaĂŻve reverseâ€ť (you can see the code here) that did a simple loop â€“ each call was called an â€śinferenceâ€ť (it involved a simple unification).

As a general rule, CPU time is roughly proportionate to number of inferences (or calls). You can get a rough idea of the complexity of the calls by looking at the â€śLipsâ€ť number â€“ the higher the number, the simpler the calls and unification.

The % CPU is how much CPU you were getting â€“ itâ€™s essentially the wall time divided into the execution time. 4% indicates that your program was mostly waiting â€“ perhaps something else was running at higher priority?

If you want to understand more about your code and why itâ€™s slow, you might look into profiling.

2 Likes

I was trying the profile measurement predicate.

1. First algorithm:
`22 samples in 0.20 sec; 453 predicates; 2034 nodes in call-graph; distortion 0%`
2. Second algorithm:
`38 samples in 0.38 sec; 411 predicates; 1717 nodes in call-graph; distortion 4%`

What is the difference between both of them? Which is seems better performance?
What samples means?
What is the # of predicates means?
What is the # of nodes means?
And what the distortion means?

Hopefully it will be my last question in this topic - It is possible to measure the DB size and memory usage? Can I use statistics/2 for that?

Thank you,
Westly

Profiling is for finding the â€śhot spotsâ€ť in your code (see show_profile/1).
However, you donâ€™t have many samples, so the results might not be very accurate.

1 Like