# Database raw and crude micro benchmark

**URL:** <https://swi-prolog.discourse.group/t/database-raw-and-crude-micro-benchmark/2994>\
**Category:** Nice to know\
**Created:** [October 2, 2020, 9:42am UTC](https://swi-prolog.discourse.group/t/database-raw-and-crude-micro-benchmark/2994 "2020-10-02T09:42:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [October 2, 2020, 9:42am UTC](https://swi-prolog.discourse.group/t/database-raw-and-crude-micro-benchmark/2994/1 "2020-10-02T09:42:01Z")

</div>

```prolog
          Database raw and crude micro benchmark           
                     1,000,000 entries                     
Database Operation Wall time
-------- --------- ---------
nb 1st lookup .......................... 0.406 secs.
trie 1st lookup .......................... 0.497 secs.
rec 1st lookup .......................... 0.614 secs.
consult 1st lookup .......................... 1.084 secs.
asrt 1st lookup .......................... 1.087 secs.
hashtable 1st lookup .......................... 1.612 secs.

nb 2nd lookup .......................... 0.412 secs.
trie 2nd lookup .......................... 0.503 secs.
consult 2nd lookup .......................... 0.581 secs.
asrt 2nd lookup .......................... 0.589 secs.
rec 2nd lookup .......................... 0.671 secs.
hashtable 2nd lookup .......................... 1.585 secs.

nb insert .......................... 0.586 secs.
trie insert .......................... 0.610 secs.
asrt insert .......................... 0.836 secs.
rec insert .......................... 1.059 secs.
hashtable insert .......................... 4.585 secs.
consult insert .......................... 21.302 secs.

```

This was copied from this [post](https://swi-prolog.discourse.group/t/new-hashtable-library/2683/31) by @SWI.

Note: @EricGT copied the post and changed the owner.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [October 2, 2020, 9:44am UTC](https://swi-prolog.discourse.group/t/database-raw-and-crude-micro-benchmark/2994/2 "2020-10-02T09:44:13Z")

</div>

With the addition of [SWI-Prolog redis client](https://github.com/SWI-Prolog/packages-redis), would be nice to see it added to list.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [October 2, 2020, 10:31am UTC](https://swi-prolog.discourse.group/t/database-raw-and-crude-micro-benchmark/2994/3 "2020-10-02T10:31:31Z")

</div>

Just thinking out loud.

Implemented the [Floyd–Warshall algorithm](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) with a variation that can be used to generate all shortest paths in a graph, see: [Finding shortest path between any two nodes using Floyd Warshall Algorithm](https://www.geeksforgeeks.org/finding-shortest-path-between-any-two-nodes-using-floyd-warshall-algorithm/?ref=rp).  
[Site](https://www-m9.ma.tum.de/graph-algorithms/spp-floyd-warshall/index_en.html) with interactive visuals for learning Floyd–Warshall algorithm

The reason I noted this is that the algorithm runs in ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/2/25652a998b91fddf8dae3e75e505d6b5e5c1f6fb.png) and just by adding several more nodes and corresponding edges to a graph, this makes for nice distribution points on a timing graph and is a real world algorithm.
