[yul-phaser] Store already loaded program in Population and make copies when computing fitness

- Until now the source code was being parsed during every fitness computation. Now the parsed program is reused and only the optimisation steps are applied each time.
This commit is contained in:
cameel
2020-02-06 09:01:10 +01:00
committed by Kamil Śliwak
parent 57fb64d467
commit e4c7b73897
4 changed files with 31 additions and 30 deletions
+3 -1
View File
@@ -17,6 +17,7 @@
#include <tools/yulPhaser/Exceptions.h>
#include <tools/yulPhaser/Population.h>
#include <tools/yulPhaser/Program.h>
#include <libsolutil/Assertions.h>
#include <libsolutil/CommonIO.h>
@@ -54,7 +55,8 @@ CharStream loadSource(string const& _sourcePath)
void runAlgorithm(string const& _sourcePath)
{
auto population = Population::makeRandom(loadSource(_sourcePath), 10);
CharStream sourceCode = loadSource(_sourcePath);
auto population = Population::makeRandom(Program::load(sourceCode), 10);
population.run(nullopt, cout);
}