# Time results understanding

**URL:** https://swi-prolog.discourse.group/t/time-results-understanding/3018
**Category:** Tools
**Tags:** discussion
**Created:** [October 8, 2020, 10:55pm UTC](https://swi-prolog.discourse.group/t/time-results-understanding/3018 "2020-10-08T22:55:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![westly](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@westly](https://swi-prolog.discourse.group/u/westly)
#### Post date: [October 8, 2020, 10:55pm UTC](https://swi-prolog.discourse.group/t/time-results-understanding/3018/1 "2020-10-08T22:55:59Z")

</div>

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

1. First algorithm time result:

```prolog
% 3,325,335 inferences, 1.344 CPU in 30.602 seconds (4% CPU, 2474668 Lips)

```

1. Second algorithm time result:

```prolog
% 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.

Thank you in advance,  
Westly

---

<div class="post-metadata">

### Author: ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)
#### Post date: [October 9, 2020, 12:03am UTC](https://swi-prolog.discourse.group/t/time-results-understanding/3018/2 "2020-10-09T00:03:11Z")

</div>

> [@westly](#):
>
> What those parameter means? (inferences, lips)

“Lips” is “Logical inferences per second”.

It comes from an old benchmark of “naïve reverse” (you can see the code [here](https://www.complang.tuwien.ac.at/ulrich/prolog_misc/lips/bench.pl)) 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](https://www.swi-prolog.org/pldoc/man?section=profiling-predicates).

---

<div class="post-metadata">

### Author: ![westly](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@westly](https://swi-prolog.discourse.group/u/westly)
#### Post date: [October 9, 2020, 5:26am UTC](https://swi-prolog.discourse.group/t/time-results-understanding/3018/3 "2020-10-09T05:26:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)
#### Post date: [October 9, 2020, 4:33pm UTC](https://swi-prolog.discourse.group/t/time-results-understanding/3018/4 "2020-10-09T16:33:23Z")

</div>

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.
