-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbenchmark.cpp
56 lines (44 loc) · 1.38 KB
/
benchmark.cpp
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
#include <iostream>
#include <stdexcept>
#include <google/protobuf/stubs/common.h>
#include "common.hpp"
void run_all_benchmarks(long iterations, long tests);
int
main(int argc, char **argv)
{
GOOGLE_PROTOBUF_VERIFY_VERSION;
if (argc < 3) {
std::cout << "usage: " << argv[0] << " N M";
std::cout << std::endl << std::endl;
std::cout << "arguments: " << std::endl;
std::cout << " N -- number of iterations" << std::endl;
std::cout << " M -- number of tests to run" << std::endl;
std::cout << std::endl;
return EXIT_SUCCESS;
}
long iterations;
long tests;
try {
int rc = str2int(argv[1], iterations);
if (rc != 0) {
return EXIT_FAILURE;
}
rc = str2int(argv[2], tests);
if (rc != 0) {
return EXIT_FAILURE;
}
} catch (std::exception& exc) {
std::cerr << "Error: " << exc.what() << std::endl;
std::cerr << "First positional argument must be an integer." << std::endl;
return EXIT_FAILURE;
}
std::cout << "version: " << GOOGLE_PROTOBUF_VERSION << std::endl;
try {
run_all_benchmarks(iterations, tests);
} catch (std::exception &exc) {
std::cerr << "Error: " << exc.what() << std::endl;
return EXIT_FAILURE;
}
google::protobuf::ShutdownProtobufLibrary();
return EXIT_SUCCESS;
}