Changeset 14328 for branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.Cli/Program.cs
- Timestamp:
- 10/08/16 12:04:25 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP.Cli/Program.cs
r14323 r14328 12 12 static void Main(string[] args) 13 13 { 14 //Stepwise().Wait();15 PerformanceTest();14 Stepwise().Wait(); 15 //PerformanceTestInterpreter(); 16 16 //PerformanceTestCodeGenerator(); 17 17 … … 22 22 static async Task Stepwise() 23 23 { 24 var program = PushGPInterpreter.Encode("( 2 3 INTEGER.* 4.1 5.2 FLOAT.+ TRUE FALSE BOOLEAN.OR )"); 24 var program = PushGPInterpreter.Encode(@"( CODE.QUOTE ( INTEGER.POP 1 ) 25 CODE.QUOTE ( CODE.DUP INTEGER.DUP 1 INTEGER.- CODE.DO INTEGER.* ) 26 INTEGER.DUP 2 INTEGER.< CODE.IF )"); 25 27 var interpreter = new PushGPInterpreter(); 26 28 27 var task = interpreter.InterpreteAsync(program);28 await interpreter.PauseAsync();29 interpreter.IntegerStack.Push(5); 30 interpreter.InterpretAsync(program, true).Wait(); 29 31 30 32 while (!interpreter.IsCompleted) … … 49 51 } 50 52 51 static void PerformanceTest ()53 static void PerformanceTestInterpreter() 52 54 { 53 55 var program = PushGPInterpreter.Encode("( 5 INTEGER.DUP INTEGER.+ )"); … … 58 60 for (var i = 0; i < 20000000; i++) 59 61 { 60 interpreter.Interpret e(program);61 interpreter. Reset();62 interpreter.Interpret(program); 63 interpreter.Clear(); 62 64 } 63 65 sw.Stop(); … … 71 73 72 74 sw.Start(); 73 var expressions = CodeGenerator.RandomCode( 10000000);75 var expressions = CodeGenerator.RandomCode(3000000); 74 76 sw.Stop(); 75 77 76 Console.WriteLine($"Count: {expressions.Count()}"); 77 Console.WriteLine(sw.Elapsed); 78 Console.WriteLine(string.Format("Generated {0} in {1}", expressions.Count(), sw.Elapsed)); 78 79 } 79 80 }
Note: See TracChangeset
for help on using the changeset viewer.