Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:32:44

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 #pragma once
0006 
0007 #include <cstdint>
0008 #include <vector>
0009 #include <random>
0010 #include <string>
0011 
0012 
0013 class JBenchUtils {
0014 
0015     std::mt19937 m_generator;
0016 
0017 public:
0018 
0019     JBenchUtils() = default;
0020 
0021     void set_seed(size_t event_number, std::string caller_name);
0022 
0023     size_t rand_size(size_t avg, double spread);
0024     int randint(int min, int max);
0025     double randdouble(double min=0.0, double max=1000.0);
0026     float randfloat(float min=0.0, float max=1000.0);
0027 
0028     uint64_t consume_cpu_ms(uint64_t millisecs, double spread=0.0);
0029     uint64_t read_memory(const std::vector<char>& buffer);
0030     uint64_t write_memory(std::vector<char>& buffer, uint64_t bytes, double spread=0.0);
0031 
0032     static void consume_cpu_us(uint64_t microsecs);
0033 
0034 };