Created
January 26, 2014 01:11
-
-
Save mini3d/8626463 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
// Distributed as Public Domain | |
#include <ctime> | |
#include <string> | |
#include <iostream> | |
typedef unsigned long ulong; | |
using namespace std; | |
struct Experiment { | |
virtual void Run() = 0; | |
void Benchmark(string name) { | |
clock_t s = clock(); | |
Run(); | |
s = clock() - s; | |
cout << name << ": " << (double)s / CLOCKS_PER_SEC << endl; | |
} | |
}; | |
struct SampleExperiment : Experiment { | |
SampleExperiment() { /* setup code goes here */ } | |
~SampleExperiment() { /* teardown code goes here */ } | |
void Run() { cout << "Benchmark code goes here" << endl; } | |
}; | |
int main(int argc, char **argv, char **arge) { | |
SampleExperiment().Benchmark("Sample"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment