-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.cpp
More file actions
59 lines (46 loc) · 1.49 KB
/
test.cpp
File metadata and controls
59 lines (46 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "Linear_event.hxx"
#include <algorithm>
#include <iostream>
#include <chrono>
#include <stdlib.h>
#include <time.h>
#include <cmath>
#include <numeric>
int main(){
#define FLASH_CACHE
const int n = 1000;
const int batchsize =1;
float inputss[n][100 * batchsize];
//std::fill_n(inputss, 100 * batchsize, 0.0);
for (int k = 0; k < n; ++k) {
for (int i = 0; i < 100 * batchsize; i++){
srand(time(0));
inputss[k][i] = rand();
}
}
std::vector<float> total_time;
const size_t bigger_than_cachesize = 10 * 1024 * 1024;
for (int k = 0; k < n; ++k ) {
#ifdef FLASH_CACHE
std::vector<float> tmp(bigger_than_cachesize);
// When you want to "flush" cache.
for(int i = 0; i < bigger_than_cachesize; i++)
{
tmp[i] = rand();
}
#endif
auto t1 = std::chrono::high_resolution_clock::now();
auto out = TMVA_SOFIE_Linear_event::infer(inputss[k]);
auto t2 = std::chrono::high_resolution_clock::now();
total_time.push_back(float(std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count()));
}
//for (auto& i: out){
//std::cout << i << ",";
//}
float sum = std::accumulate(total_time.begin(), total_time.end(), 0.0);
float mean = sum / total_time.size();
float sq_sum = std::inner_product(total_time.begin(), total_time.end(), total_time.begin(), 0.0);
float std = std::sqrt(sq_sum / total_time.size() - mean * mean);
std::cout << std::endl << mean << std::endl;
std::cout << std << std::endl;
}