First official checkin.
5 * Created by Jens Alfke on 9/12/09.
6 * Copyright 2009 Jens Alfke. All rights reserved.
7 * BSD-Licensed: See the file "LICENSE.txt" for details.
10 #include "TestUtils.h"
17 std::ostream& operator<< (std::ostream &out, const Blob &blob) {
18 char str[blob.length+1];
19 memcpy(str,blob.bytes,blob.length);
25 void shuffle(int a[], int n, unsigned seed) {
30 fprintf(stderr,"shuffle(n=%i, seed=%u)\n", n,seed);
32 for (int i=0; i<n-1; i++) {
33 int j = i + (random() % (n-i));
45 sWords = new char*[250000];
48 FILE *in = fopen("/usr/share/dict/words", "r");
51 while (NULL != (word=fgetln(in,&wordLen))) {
52 if (word[wordLen-1]=='\n')
54 char *str = new char[wordLen+1];
55 memcpy(str, word, wordLen);
57 sWords[sNWords] = str;
58 //if( sNWords % 10000 == 0)
59 // printf("'%s' ... ", sWords[sNWords]->string());
68 Timer::Timer (const char *operation, int divisor) {
69 _operation = operation;
76 double elapsedCPU = (clock() - _cpuTime) / 1.0e6;
77 double elapsed = now() - _time;
78 printf("### %s took %.6lf sec (used %.6lf sec CPU)", _operation, elapsed, elapsedCPU);
80 printf(" ... per item: %.3lf usec, %.3lf usec CPU", elapsed/_divisor*1e6, elapsedCPU/_divisor*1e6);
86 gettimeofday(&t,NULL);
87 return (double)t.tv_sec + t.tv_usec/1.0e6;
93 using namespace Mooseyard;
95 int main(int argc, char **argv) {
98 ::testing::InitGoogleTest(&argc, argv);
99 return RUN_ALL_TESTS();
100 } catch (const File::Error &err) {
101 fprintf(stderr, "\n*** File::Error thrown: %i/%s\n", err.code,err.message);