forked from AlexIzydorczyk/sudoku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.hpp
39 lines (34 loc) · 1004 Bytes
/
tests.hpp
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
/*
Matt Olson
Alex Izydorczyk
Function declarations for unit-testing
*/
#pragma once
#include <iostream>
#include <regex>
#include <sstream>
#include "solver.hpp"
#include "altproj.hpp"
#include "game.hpp"
#include <ctime>
#include <ratio>
#include <chrono>
using namespace std;
// Unit testing code
// Based on http://stackoverflow.com/questions/29719999/
// testing-function-for-speed-performance-in-cpp
template<typename TimeT> //template as measurement size (seconds, milliseconds)
struct measure
{
template<typename F, typename ...Args>
static typename TimeT::rep execution(F func, Args&&... args)
{
auto start = std::chrono::high_resolution_clock::now();
func(std::forward<Args>(args)...); //forward arguments to function
auto duration = std::chrono::duration_cast< TimeT>
(std::chrono::high_resolution_clock::now() - start);
return duration.count();
}
};
//Unit test
void unitTest(int size, int nobs, int ntimes, bool verbose);