Vector access speed versus on-the-fly generation
Hi all,
I have been testing various methods for a search optimization program. Part of this testing is to see how I can better speed up the solution checking. As it involves combinations I am using the lottery, 6 from 49 for my benchmarking, just shy of 14 million combinations.
I have found that reading the combinations stored in a vector is like 20% slower than just generating each combination on the fly, which surprised me - I thought that once generated a lookup like this would be faster? Also my on-the-fly routine isn't even really that optimal, I am sure it could be improved.
Is this to be expected? I am not compiling with any optimisations, the runtime version evaluates the value of six integers with if statements to obtain the combinations as you go, pretty basic.
Note: The vector method is 2 dimensional - Plus I am just using straight ints + vectors for now as a starting view, rather than considering any lower level / smaller datatype options