Created
October 31, 2014 01:52
-
-
Save Mischa-Alff/e6407a9a9b5894a317a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iostream> | |
#include <fea/util/noise.hpp> | |
int main() | |
{ | |
fea::Noise noise; | |
uint64_t min(-1), max(0), avg(0); | |
int steps = 10; | |
for(int n=0; n < steps; ++n) | |
{ | |
auto start = std::chrono::high_resolution_clock::now(); | |
for(unsigned int i=0; i < 100000000; ++i) | |
{ | |
noise.simplexOctave3D(i*0.1f, i*2.f, i*3.f); | |
} | |
auto end = std::chrono::high_resolution_clock::now(); | |
uint64_t current = std::chrono::duration_cast<std::chrono::microseconds>(end-start).count(); | |
std::cout<<"Step: "<<current<<"us"<<std::endl; | |
min = std::min(current, min); | |
max = std::max(current, max); | |
avg += current; | |
} | |
avg /= steps; | |
std::cout<<"Times (min, max, avg): "<<min<<"us, "<<max<<"us, "<<avg<<"us"<<std::endl; | |
} | |
/* | |
Built on ArchLinux x86_64 with GCC 4.9.1 | |
Featherkit-util linked as static library | |
CPU: Intel Core i7 4770 @ 3.4 GHz | |
Tests were performed with TurboBoost on, and the clock speed was 3.75GHz | |
Featherkit with `-O3`: | |
- C++ Noise: | |
- With std::pow(): | |
- Times (min, max, avg): 18500990us, 19314295us, 18761359us | |
- With expanded exponent: | |
- Times (min, max, avg): 13590441us, 13778924us, 13641680us | |
- With expanded exponent and fast_floor: | |
- Times (min, max, avg): 12741825us, 12785273us, 12761292us | |
- ASM Noise: | |
- Times (min, max, avg): 17619293us, 18048159us, 17756850us | |
Featherkit with `-O3 -march=native -mfpmath=sse`: | |
- C++ Noise: | |
- With std::pow(): | |
- Times (min, max, avg): 16363849us, 16540378us, 16425663us | |
- With expanded exponent: | |
- Times (min, max, avg): 12010800us, 12160890us, 12042282us | |
- With expanded exponent and fast_floor: | |
- Times (min, max, avg): 11155214us, 11217809us, 11175114us | |
- ASM Noise: | |
- Times (min, max, avg): 17765922us, 17830874us, 17787408us | |
If I compile the example with `-O3 -march=native -mfpmath=sse`, I get: | |
- C++ Noise: | |
- With expanded exponent: | |
- Times (min, max, avg): 11598168us, 11839490us, 11654674us | |
- With expanded exponent and fast_floor: | |
- Times (min, max, avg): 10935452us, 10988102us, 10964837us | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment