Skip to content

Commit

Permalink
I have no idea whether I wanted to commit this or not
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Nov 30, 2024
1 parent ea548ae commit b13e8f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions functions/benchmarking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "absl/strings/str_format.h"
#include "geometry/sign.hpp"
#include "mathematica/logger.hpp"
#include "mathematica/mathematica.hpp"
#include "numerics/root_finders.hpp"
#include "quantities/elementary_functions.hpp"
#include "quantities/quantities.hpp"
Expand All @@ -11,6 +13,8 @@ namespace functions {
namespace _benchmarking {

using namespace principia::geometry::_sign;
using namespace principia::mathematica::_logger;
using namespace principia::mathematica::_mathematica;
using namespace principia::numerics::_root_finders;
using namespace principia::quantities::_elementary_functions;
using namespace principia::quantities::_quantities;
Expand Down Expand Up @@ -155,20 +159,22 @@ __declspec(noinline) MeasurementResult
constexpr std::int64_t n = 1 << 16;
for (int j = 0; j < samples; ++j) {
std::array<double, static_cast<std::size_t>(n)> inputs;
for (std::int64_t i = 0; i < n; ++i) {
/* for (std::int64_t i = 0; i < n; ++i) {
inputs[i] = get_input();
}
}*/
auto const start = __rdtsc();
double x = inputs[0];
for (std::int64_t i = 0; i < n; ++i) {
double const result = f(x);
x = result + inputs[i] - result;
x = result + get_input() - result;
}
auto const stop = __rdtsc();
LOG(INFO) << x;
cycle_counts.push_back((double)(stop - start) / n);

Check warning on line 173 in functions/benchmarking.cpp

View workflow job for this annotation

GitHub Actions / check-cpp

readability/casting

Using C-style cast. Use static_cast<double>(...) instead
}
MeasurementResult latency = LogNormalTerminus(cycle_counts);
static Logger logger(TEMP_DIR / "meow.wl");
logger.Append("counts", cycle_counts);
latency = {.value = latency.value - identity_latency.value,
.standard_uncertainty =
Sqrt(Pow<2>(latency.standard_uncertainty) +
Expand Down
8 changes: 4 additions & 4 deletions functions/sin_cos_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ TEST_F(SinCosBenchmark, StdSinLatency) {
// calling convention.
std::cout << "std::sin latency: "
<< BenchmarkFunctionLatency(
&std::sin, [this]() { return uniformly_at_(random_); }, 10000)
&std::sin, [this]() { return uniformly_at_(random_); }, 100000)

Check warning on line 33 in functions/sin_cos_benchmark.cpp

View workflow job for this annotation

GitHub Actions / check-cpp

whitespace/line_length

Lines should be <= 80 characters long
.ToGUMString()
<< " cycles\n";
}

TEST_F(SinCosBenchmark, PrincipiaSinLatency) {
std::cout << "Principia Sin latency: "
<< BenchmarkFunctionLatency(
&Sin, [this]() { return uniformly_at_(random_); }, 10000)
&Sin, [this]() { return uniformly_at_(random_); }, 100000)
.ToGUMString()
<< " cycles\n";
}

TEST_F(SinCosBenchmark, StdSinThroughput) {
std::cout << "std::sin reciprocal throughput: "
<< BenchmarkFunctionThroughput(
&std::sin, [this]() { return uniformly_at_(random_); }, 10000)
&std::sin, [this]() { return uniformly_at_(random_); }, 100000)

Check warning on line 49 in functions/sin_cos_benchmark.cpp

View workflow job for this annotation

GitHub Actions / check-cpp

whitespace/line_length

Lines should be <= 80 characters long
.ToGUMString()
<< " cycles\n";
}

TEST_F(SinCosBenchmark, PrincipiaSinThroughput) {
std::cout << "Principia Sin reciprocal throughput: "
<< BenchmarkFunctionThroughput(
&Sin, [this]() { return uniformly_at_(random_); }, 10000)
&Sin, [this]() { return uniformly_at_(random_); }, 100000)
.ToGUMString()
<< " cycles\n";
}
Expand Down

0 comments on commit b13e8f1

Please sign in to comment.