aboutsummaryrefslogtreecommitdiff
path: root/src/tests/speed.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-03-30 22:33:41 +0000
committerMike Buland <eichlan@xagasoft.com>2011-03-30 22:33:41 +0000
commit4b9289cfb260f4bcecaf23a810584ef6ef8e8501 (patch)
tree79136af08c7e42ba3322f0d73e9779e4354b318a /src/tests/speed.cpp
parentc7636dc954eddfe58f7959392602fbc9072d77e7 (diff)
downloadlibbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.gz
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.bz2
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.tar.xz
libbu++-4b9289cfb260f4bcecaf23a810584ef6ef8e8501.zip
Ok, string stuff is working much, much better, a load of new unit tests have
been added, and I deleted a whole slew of stupid old tests that I don't need.
Diffstat (limited to '')
-rw-r--r--src/tests/speed.cpp58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/tests/speed.cpp b/src/tests/speed.cpp
deleted file mode 100644
index 2fa29aa..0000000
--- a/src/tests/speed.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/string.h"
9#include <sys/time.h>
10
11template<typename a>
12struct tstCopy
13{
14 tstCopy( const a &src ) :
15 src( src )
16 {
17 }
18
19 void operator()()
20 {
21 a tmp = src;
22 }
23
24 a src;
25};
26
27template<typename f>
28double runTest( f fnc )
29{
30 struct timeval tStart, tEnd;
31 int j = 0;
32 gettimeofday( &tStart, NULL );
33 for(; j < 500000; j++ )
34 fnc();
35 gettimeofday( &tEnd, NULL );
36
37 return (double)(tEnd.tv_sec-tStart.tv_sec)+
38 (double)(tEnd.tv_usec-tStart.tv_usec)/1000000.0;
39}
40
41template<typename tst>
42void fullTest( tst t )
43{
44 double dTotal;
45 int iCount = 10;
46 for( int j = 0; j < iCount; j++ )
47 dTotal += runTest( t );
48 printf("Average time: %f\n", dTotal/iCount );
49}
50
51int main()
52{
53 Bu::String str;
54 for( int j = 0; j < 500; j++ )
55 str.append("Hey, this is a test string. It will be reapeated many, many times. How's that?");
56 fullTest( tstCopy<Bu::String>( str ) );
57}
58