-
Notifications
You must be signed in to change notification settings - Fork 0
/
sincos.cpp
42 lines (35 loc) · 1.04 KB
/
sincos.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
#include "sincos.h"
#define CATCH_CONFIG_ENABLE_BENCHMARKING
#define CATCH_CONFIG_RUNNER
#include <catch2/catch.hpp>
#include <random>
#include "utils.h"
using real_type = double;
std::vector<real_type> inputs;
std::vector<real_type> sinResult;
std::vector<real_type> cosResult;
TEST_CASE("SINCOS") {
sinResult.resize(TESTS);
cosResult.resize(TESTS);
BENCHMARK("STD SIN COS") {
for (int i = 0; i < TESTS; ++i) {
mySinCos(inputs[i], sinResult[i], cosResult[i]);
}
};
BENCHMARK("STD SINCOS") {
for (int i = 0; i < TESTS; ++i) {
sincos(inputs[i], &sinResult[i], &cosResult[i]);
}
};
}
int main(int argc, char *argv[]) {
auto seed = std::random_device()();
std::cout << "Seed " << seed << std::endl;
std::default_random_engine rng{seed};
std::uniform_real_distribution<real_type> distribution{0, 2 * M_PI};
inputs.resize(TESTS);
for (int i = 0; i < TESTS; ++i) {
inputs[i] = distribution(rng);
}
return Catch::Session().run(argc, argv);
}