Click here to Skip to main content
15,879,239 members
Articles / Programming Languages / C++

KISS code block execution-speed benchmark

Rate me:
Please Sign up or sign in to vote.
4.40/5 (5 votes)
31 May 2006 55K   379   27  
A utility for "Keep It Simple Stupid" code block execution-speed benchmarking.
//////////////////////////////////////////////////////////////
//
//	file:		bench_use.cpp
//
//	purpose:	demonstration of benchmark utility usage
//
//  copyright:	(c) 2005 Oto Sp�l
//				
//				This software is provided 'as-is', without any 
//				express or implied warranty. In no event will the 
//				authors be held liable for any damages arising from 
//				the use of this software.
//
//				Permission is granted to anyone to use this software 
//				for any purpose, including commercial applications, 
//				and to alter it and redistribute it freely, subject 
//				to the following restrictions:
//				
//				1.	The origin of this software must not be misrepresented; 
//					you must not claim that you wrote the original software. 
//					If you use this software in a product, an acknowledgment 
//					in the product documentation would be appreciated but is 
//					not required.
//				2.	Altered source versions must be plainly marked as such, 
//					and must not be misrepresented as being the original 
//					software.
//				3.	This notice may not be removed or altered from any 
//					source distribution.
//
//	history:	2005-11-08 OS
//				- file crated
//
//	contact:	info@armego.sk
//				www.armego.sk
//
//////////////////////////////////////////////////////////////

#include <benchmark.h>

//////////////////////////////////////////////////////////////
//					  test application						//
//////////////////////////////////////////////////////////////

#include <math.h>
#define E		2.71828182845904523536

START_BENCHMARK

	SET_DESCRIPTION("Block A: int a = 2+2\nBlock B: int b = 4/2")	//description changed
	EXEBLOCK_A
	int a = 2+2;
	EXEBLOCK_B
	int b = 4/2;
	EVALUATE

	SET_DESCRIPTION("Block A: pow(E, 5.123)\nBlock B: exp(5.123)")	//description changed
	SET_ENVIRONMENT(CLEAN)											//environment changed
	EXEBLOCK_A
	pow(E, 5.123);
	EXEBLOCK_B
	exp(5.123);
	EVALUATE

CLOSE_BENCHMARK

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Slovakia Slovakia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions