public
Created

  • Download Gist
bench.cpp
C++
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
#include "foo.h"
 
void bench()
{
Radians rad(PI);
Radians tmp(0);
 
for (int i=0; i<100000000; ++i)
{
tmp=mul(rad);
rad=div(tmp);
}
}
 
void bench_ref()
{
Radians rad(PI);
Radians tmp(0);
 
for (int i=0; i<100000000; ++i)
{
tmp=mul_ref(rad);
rad=div_ref(tmp);
}
}
foo.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include "foo.h"
 
Radians mul(Radians r)
{
return r*2;
}
Radians div(Radians r)
{
return r/2;
}
 
Radians mul_ref(const Radians &r)
{
return r*2;
}
Radians div_ref(const Radians &r)
{
return r/2;
}
foo.h
C
1 2 3 4 5 6 7
#include "degrad.h"
 
Radians mul(Radians);
Radians div(Radians);
 
Radians mul_ref(const Radians);
Radians div_ref(const Radians);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.