In your README, you give g++ -o output.out *.cpp as an example build command. By default, this builds without any optimization, resulting in the simulator running much slower than it could. Giving g++ the -O3 argument (that's a capital letter 'O' and the number 3, for optimization level 3), gives much better performance. For example (on my desktop, a Ryzen 7800X3D):
cibyr@greybox:~/src/PlatinumSimulator$ g++ -o simulator *.cpp
cibyr@greybox:~/src/PlatinumSimulator$ time ./simulator -s 65536 -t 16
<booting>
Loaded Commands
Chunk size: 4096
./simulationResults/default
Player won. Lowest hp -> 46 // Seed: 1840 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 5905 // Fainted: 0
Player won. Lowest hp -> 49 // Seed: 10266 // Fainted: 0
Player won. Lowest hp -> 50 // Seed: 12469 // Fainted: 0
Player won. Lowest hp -> 56 // Seed: 16815 // Fainted: 0
Player won. Lowest hp -> 52 // Seed: 20890 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 26345 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 31765 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 33150 // Fainted: 0
Player won. Lowest hp -> 49 // Seed: 39152 // Fainted: 0
Player won. Lowest hp -> 49 // Seed: 40999 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 48376 // Fainted: 0
Player won. Lowest hp -> 46 // Seed: 52155 // Fainted: 0
Player won. Lowest hp -> 54 // Seed: 55773 // Fainted: 0
Player won. Lowest hp -> 51 // Seed: 57399 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 61966 // Fainted: 0
real 0m5.239s
user 1m20.945s
sys 0m0.031s
cibyr@greybox:~/src/PlatinumSimulator$ g++ -O3 -o simulator *.cpp
cibyr@greybox:~/src/PlatinumSimulator$ time ./simulator -s 65536 -t 16
<booting>
Loaded Commands
Chunk size: 4096
./simulationResults/default
Player won. Lowest hp -> 46 // Seed: 1840 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 5905 // Fainted: 0
Player won. Lowest hp -> 49 // Seed: 10266 // Fainted: 0
Player won. Lowest hp -> 50 // Seed: 12469 // Fainted: 0
Player won. Lowest hp -> 56 // Seed: 16815 // Fainted: 0
Player won. Lowest hp -> 52 // Seed: 20890 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 26345 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 31765 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 33150 // Fainted: 0
Player won. Lowest hp -> 49 // Seed: 39152 // Fainted: 0
Player won. Lowest hp -> 49 // Seed: 40999 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 48376 // Fainted: 0
Player won. Lowest hp -> 46 // Seed: 52155 // Fainted: 0
Player won. Lowest hp -> 54 // Seed: 55773 // Fainted: 0
Player won. Lowest hp -> 51 // Seed: 57399 // Fainted: 0
Player won. Lowest hp -> 48 // Seed: 61966 // Fainted: 0
real 0m1.875s
user 0m28.571s
sys 0m0.061s
That's a nearly 3x speedup (honestly, not as dramatic as I expected) for basically zero effort.
In your README, you give
g++ -o output.out *.cpp
as an example build command. By default, this builds without any optimization, resulting in the simulator running much slower than it could. Givingg++
the-O3
argument (that's a capital letter 'O' and the number 3, for optimization level 3), gives much better performance. For example (on my desktop, a Ryzen 7800X3D):That's a nearly 3x speedup (honestly, not as dramatic as I expected) for basically zero effort.