-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetics.cpp
More file actions
43 lines (34 loc) · 1 KB
/
Copy pathArithmetics.cpp
File metadata and controls
43 lines (34 loc) · 1 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
#include "BenchmarkSupport.hpp"
#include <arithmetics/core/CoreModule.hpp>
namespace pegium::bench {
namespace {
std::string make_source(std::size_t targetBytes) {
std::string source;
source.reserve(targetBytes + 1024);
source += "module Bench\n\n";
std::size_t index = 0;
while (source.size() < targetBytes) {
if (index == 0) {
source += "def value0: 1 + 2;\n";
} else {
source += "def value" + std::to_string(index) + ": value" +
std::to_string(index - 1) + " + 1;\n";
}
if (index % 16 == 0) {
source += "value" + std::to_string(index) + ";\n";
}
++index;
}
return source;
}
} // namespace
void register_arithmetics_benchmarks(BenchmarkRegistry ®istry) {
register_full_build_benchmark(
registry,
{.name = "arithmetics",
.languageId = "arithmetics",
.extension = ".calc",
.registerLanguages = arithmetics::registerArithmeticsCoreServices,
.makeSource = make_source});
}
} // namespace pegium::bench