jit-performance.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "../aes_hash.hpp"
  2. #include "../jit_compiler_x86.hpp"
  3. #include "../program.hpp"
  4. #include "utility.hpp"
  5. #include "stopwatch.hpp"
  6. #include "../blake2/blake2.h"
  7. #include "../reciprocal.h"
  8. int main(int argc, char** argv) {
  9. int count;
  10. readInt(argc, argv, count, 1000000);
  11. const char seed[] = "JIT performance test seed";
  12. uint8_t hash[64];
  13. blake2b(&hash, sizeof hash, &seed, sizeof seed, nullptr, 0);
  14. randomx::ProgramConfiguration config;
  15. randomx::Program program;
  16. randomx::JitCompilerX86 jit;
  17. std::cout << "Compiling " << count << " programs..." << std::endl;
  18. Stopwatch sw(true);
  19. for (int i = 0; i < count; ++i) {
  20. fillAes1Rx4<false>(hash, sizeof(program), &program);
  21. auto addressRegisters = program.getEntropy(12);
  22. config.readReg0 = 0 + (addressRegisters & 1);
  23. addressRegisters >>= 1;
  24. config.readReg1 = 2 + (addressRegisters & 1);
  25. addressRegisters >>= 1;
  26. config.readReg2 = 4 + (addressRegisters & 1);
  27. addressRegisters >>= 1;
  28. config.readReg3 = 6 + (addressRegisters & 1);
  29. jit.generateProgram(program, config);
  30. }
  31. std::cout << "Elapsed: " << sw.getElapsed() << " s" << std::endl;
  32. dump((const char*)jit.getProgramFunc(), randomx::CodeSize, "program.bin");
  33. return 0;
  34. }