-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathbenchmark.cpp
More file actions
65 lines (58 loc) · 1.89 KB
/
benchmark.cpp
File metadata and controls
65 lines (58 loc) · 1.89 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
60
61
62
63
64
65
#include "src/cmdline.h"
#include "src/benchmark.h"
#include <iostream>
void info_message() {
std::cout
<< "We define the number of bytes to be the number of *input* bytes.\n";
std::cout
<< "We define a 'char' to be a code point (between 1 and 4 bytes).\n";
#ifdef ICU_AVAILABLE
std::cout << "Using ICU version " << U_ICU_VERSION << std::endl;
#endif
#ifdef _LIBICONV_VERSION
std::cout << "Using iconv version " << _LIBICONV_VERSION << std::endl;
#endif
#if defined(__clang__)
std::cout << "Compiler: Clang " << __clang_major__ << "." << __clang_minor__
<< "." << __clang_patchlevel__ << "\n";
#elif defined(__GNUC__)
std::cout << "Compiler: GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "."
<< __GNUC_PATCHLEVEL__ << "\n";
#elif defined(_MSC_VER)
std::cout << "Compiler: MSVC " << _MSC_VER << "\n";
#endif
std::cout << "SIMDUTF version: " << SIMDUTF_VERSION << "\n";
std::cout << "System: " << simdutf::get_active_implementation()->name()
<< "\n";
std::cout << "===========================\n";
}
int main(int argc, char *argv[]) {
#ifdef INOUE2008
inoue2008::inoue_test(); // minimal testing
#endif
using simdutf::benchmarks::CommandLine;
CommandLine cmdline;
try {
cmdline = CommandLine::parse_arguments(argc, argv);
if (cmdline.show_help) {
CommandLine::print_help();
return EXIT_SUCCESS;
}
if (cmdline.empty()) {
CommandLine::print_help();
return EXIT_FAILURE;
}
} catch (const std::exception &e) {
printf("%s\n", e.what());
return EXIT_FAILURE;
}
using simdutf::benchmarks::Benchmark;
using simdutf::benchmarks::ListingMode;
Benchmark benchmark{Benchmark::create(cmdline)};
if (cmdline.show_procedures != ListingMode::None) {
benchmark.list_procedures(cmdline.show_procedures);
return EXIT_SUCCESS;
}
info_message();
return benchmark.run() ? EXIT_SUCCESS : EXIT_FAILURE;
}