Performance: composite term access vs. fact base access


I have some simple configuration data that is stored in the Prolog fact base.

There is a goal / process (say, hpg/1) that i am fine tuning for high performance. Currently, hpg/1 retrieves configuration data in its body through a fact access, e.g. config_a(A).

The same high performance goal also has some global configuration data passed as argument, in form of a tuple with “accessor goals”: such as:

get_a(Configuration, A), with Configuration bound to a structure such config(_A, _B, _C) and get_a(config(A, _, _, _), A).

Configuration is passed as a “context” argument to the high performance goal hpg(Context).

I am curious which kind of access if faster:

config_a(A) – that is a hash lookup

or get_a(Context) – that is a structure binding lookup – which would require fact lookup only once before the high performance goal is performed.

I am counting “cycles” :slight_smile:

any thoughts are much appreciated,