summaryrefslogtreecommitdiff
path: root/src/tests/fstring.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 02:14:08 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 02:14:08 +0000
commitf5aca1a1b402bd7ebc944dc6e6fe65828d863365 (patch)
tree4a0fdd8e166d5c4b03543279d332b9a858ef62df /src/tests/fstring.cpp
parent10c557562e1d67c55314c212371ea9cb7f802863 (diff)
downloadlibbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.tar.gz
libbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.tar.bz2
libbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.tar.xz
libbu++-f5aca1a1b402bd7ebc944dc6e6fe65828d863365.zip
Bu::FString is now String, and there's a shell script to fix any other programs
that were using fstring, I hope.
Diffstat (limited to 'src/tests/fstring.cpp')
-rw-r--r--src/tests/fstring.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/tests/fstring.cpp b/src/tests/fstring.cpp
index c343172..acc3558 100644
--- a/src/tests/fstring.cpp
+++ b/src/tests/fstring.cpp
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include "bu/hash.h" 8#include "bu/hash.h"
9#include "bu/fstring.h" 9#include "bu/string.h"
10#include <sys/time.h> 10#include <sys/time.h>
11#include <string> 11#include <string>
12 12
@@ -27,9 +27,9 @@ inline double getTime()
27} 27}
28#endif 28#endif
29 29
30Bu::FString genThing() 30Bu::String genThing()
31{ 31{
32 Bu::FString bob; 32 Bu::String bob;
33 bob.append("ab "); 33 bob.append("ab ");
34 bob += "cd "; 34 bob += "cd ";
35 bob += "efg"; 35 bob += "efg";
@@ -39,7 +39,7 @@ Bu::FString genThing()
39 return bob; 39 return bob;
40} 40}
41 41
42void thing( Bu::FString str ) 42void thing( Bu::String str )
43{ 43{
44 printf("Hey: %s\n", str.getStr() ); 44 printf("Hey: %s\n", str.getStr() );
45} 45}
@@ -49,21 +49,21 @@ void copyfunc( std::string temp )
49 temp += "Hi"; 49 temp += "Hi";
50} 50}
51 51
52void copyfunc( Bu::FString temp ) 52void copyfunc( Bu::String temp )
53{ 53{
54 temp += "Hi"; 54 temp += "Hi";
55} 55}
56 56
57void doTimings() 57void doTimings()
58{ 58{
59 Bu::FString fs1, fs2; 59 Bu::String fs1, fs2;
60 std::string ss1, ss2; 60 std::string ss1, ss2;
61 double dStart, dEnd, tfs1, tfs2, tfs3, tss1, tss2, tss3; 61 double dStart, dEnd, tfs1, tfs2, tfs3, tss1, tss2, tss3;
62 int nChars = 500000, nChunks=5000, nCopies=5000000, nChunkSize=1024*4; 62 int nChars = 500000, nChunks=5000, nCopies=5000000, nChunkSize=1024*4;
63 char *buf = new char[nChunkSize]; 63 char *buf = new char[nChunkSize];
64 memset( buf, '!', nChunkSize ); 64 memset( buf, '!', nChunkSize );
65 65
66 printf("Timing Bu::FString single chars...\n"); 66 printf("Timing Bu::String single chars...\n");
67 dStart = getTime(); 67 dStart = getTime();
68 for( int j = 0; j < nChars; j++ ) fs1 += (char)('a'+(j%26)); 68 for( int j = 0; j < nChars; j++ ) fs1 += (char)('a'+(j%26));
69 fs1.getStr(); 69 fs1.getStr();
@@ -77,7 +77,7 @@ void doTimings()
77 dEnd = getTime(); 77 dEnd = getTime();
78 tss1 = dEnd-dStart; 78 tss1 = dEnd-dStart;
79 79
80 printf("Timing Bu::FString %d char chunks...\n", nChunkSize); 80 printf("Timing Bu::String %d char chunks...\n", nChunkSize);
81 dStart = getTime(); 81 dStart = getTime();
82 for( int j = 0; j < nChunks; j++ ) fs2.append(buf, nChunkSize); 82 for( int j = 0; j < nChunks; j++ ) fs2.append(buf, nChunkSize);
83 fs2.getStr(); 83 fs2.getStr();
@@ -93,9 +93,9 @@ void doTimings()
93 93
94 fs2 = "Hello there."; 94 fs2 = "Hello there.";
95 ss2 = "Hello there."; 95 ss2 = "Hello there.";
96 printf("Timing Bu::FString copies...\n"); 96 printf("Timing Bu::String copies...\n");
97 dStart = getTime(); 97 dStart = getTime();
98 for( int j = 0; j < nCopies; j++ ) Bu::FString stmp = fs2; 98 for( int j = 0; j < nCopies; j++ ) Bu::String stmp = fs2;
99 dEnd = getTime(); 99 dEnd = getTime();
100 tfs3 = dEnd-dStart; 100 tfs3 = dEnd-dStart;
101 101
@@ -107,7 +107,7 @@ void doTimings()
107 107
108 printf( 108 printf(
109 "Results: singles: chunks: copies:\n" 109 "Results: singles: chunks: copies:\n"
110 "Bu::FString %10.2f/s %10.2f/s %10.2f/s\n" 110 "Bu::String %10.2f/s %10.2f/s %10.2f/s\n"
111 "std::string %10.2f/s %10.2f/s %10.2f/s\n", 111 "std::string %10.2f/s %10.2f/s %10.2f/s\n",
112 nChars/tfs1, nChunks/tfs2, nCopies/tfs3, 112 nChars/tfs1, nChunks/tfs2, nCopies/tfs3,
113 nChars/tss1, nChunks/tss2, nCopies/tss3 ); 113 nChars/tss1, nChunks/tss2, nCopies/tss3 );
@@ -118,16 +118,16 @@ void doTimings()
118#define pem printf("---------\n%08tX: %s\n%08tX: %s\n", (ptrdiff_t)str.getStr(), str.getStr(), (ptrdiff_t)str2.getStr(), str2.getStr() ); 118#define pem printf("---------\n%08tX: %s\n%08tX: %s\n", (ptrdiff_t)str.getStr(), str.getStr(), (ptrdiff_t)str2.getStr(), str2.getStr() );
119int main( ) 119int main( )
120{ 120{
121 Bu::FString fs1; 121 Bu::String fs1;
122 for( int j = 0; j < 500000; j++ ) fs1 += (char)('a'+(j%26)); 122 for( int j = 0; j < 500000; j++ ) fs1 += (char)('a'+(j%26));
123 return 0; 123 return 0;
124 124
125 Bu::FString str("th"); 125 Bu::String str("th");
126 126
127 str.prepend("Hello "); 127 str.prepend("Hello ");
128 str.append("ere."); 128 str.append("ere.");
129 129
130 Bu::FString str2( str ); 130 Bu::String str2( str );
131 pem; 131 pem;
132 str += " What's up?"; 132 str += " What's up?";
133 pem; 133 pem;