Sha256: 7665364eb9ebca579736f72bcf636317649c7745f24145d86d46c0667e23cd20

Contents?: true

Size: 1.05 KB

Versions: 30

Compression:

Stored size: 1.05 KB

Contents

//
//  Benchmark.h
//  DictionarySort
//
//  Created by Samuel Williams on 2/11/11.
//  Copyright, 2014, by Samuel G. D. Williams. <http://www.codeotaku.com>
//

#pragma once

#include <ctime>

// A timer class for quickly checking the wall-clock performance of code.
namespace Benchmark
{
	typedef double TimeT;

	class WallTime {
	protected:
		mutable TimeT _last, _total;

	public:
		WallTime ();

		void reset ();
		TimeT total () const;
	};

	class ProcessorTime {
	protected:
		mutable std::clock_t _last, _total;

	public:
		ProcessorTime();

		void reset ();
		TimeT total () const;
	};

	class Timer {
	protected:
		WallTime _wall_time;
		ProcessorTime _processor_time;

	public:
		Timer();

		const WallTime & wall_time() const { return _wall_time; }
		const ProcessorTime & processor_time() const { return _processor_time; }

		void reset ();

		struct Sample {
			TimeT wall_time_total;
			TimeT processor_time_total;

			TimeT approximate_processor_usage() const {
				return processor_time_total / wall_time_total;
			}
		};

		Sample sample() const;
	};
	
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
build-graph-2.1.1 spec/build/graph/program/Benchmark.h
build-graph-2.1.0 spec/build/graph/program/Benchmark.h
build-graph-2.0.3 spec/build/graph/program/Benchmark.h
build-graph-2.0.2 spec/build/graph/program/Benchmark.h
build-graph-2.0.1 spec/build/graph/program/Benchmark.h
build-graph-2.0.0 spec/build/graph/program/Benchmark.h
build-graph-1.5.1 spec/build/graph/program/Benchmark.h
build-graph-1.4.3 spec/build/graph/program/Benchmark.h
build-graph-1.4.2 spec/build/graph/program/Benchmark.h
build-graph-1.4.1 spec/build/graph/program/Benchmark.h
build-graph-1.4.0 spec/build/graph/program/Benchmark.h
build-graph-1.3.0 spec/build/graph/program/Benchmark.h
build-graph-1.2.1 spec/build/graph/program/Benchmark.h
build-graph-1.2.0 spec/build/graph/program/Benchmark.h
build-graph-1.1.0 spec/build/graph/program/Benchmark.h
build-graph-1.0.6 spec/build/graph/program/Benchmark.h
build-graph-1.0.5 spec/build/graph/program/Benchmark.h
build-graph-1.0.4 spec/build/graph/program/Benchmark.h
build-graph-1.0.3 spec/build/graph/program/Benchmark.h
build-graph-1.0.2 spec/build/graph/program/Benchmark.h