Auto benchmarking with moon

1

A script in C or C ++ could write algorithms on Lua (by brute force , that is, test several possible combinations) based on a database with algorithm results.

The idea is to arrive at the most efficient algorithm for a given goal, for example, I developed an algorithm for calculating statistics, I want to get to a more efficient one without losing focus.

Is there any library or way to test the speed of a code in Lua or C / C ++ using C ++?

    
asked by anonymous 02.07.2014 / 00:27

1 answer

4

It's not so clear how you're generating the moon algorithms, but there are two simple ways to get the code to run. The first is to link your program with the moon interpreter as a library. Then you can execute code that is in a string by loading it with luaL_loadstring and then invoking lua_pcall . The other way would be to save the script to a file and then use system("lua myscript.lua") , since the interpreter is installed on your system.

Having this you can do a very simple but not so accurate benchmark using the clock() or the chrono classes of C ++. The idea is to measure the time before and after the execution and calculate the difference. It is worth noting that it is important to make multiple measurements to ensure a good result.

    
02.07.2014 / 00:46