Last active
May 24, 2017 15:24
-
-
Save komamitsu/c4c811167762fe63b50d45c674c983b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cc -c dartest.cpp && c++ -o dartest dartest.o | |
#include <chrono> | |
#include <iostream> | |
#include <string> | |
#include <algorithm> | |
#include <fstream> | |
#include <darts.h> | |
using namespace std; | |
int main (int argc, char **argv) | |
{ | |
Darts::DoubleArray da; | |
if (da.open("/Users/komamitsu/src/dart/darts-0.32/uuids.da") == -1) return -1; | |
ifstream infile("/Users/komamitsu/tmp/uuids"); | |
Darts::DoubleArray::key_type uuid[1024]; | |
Darts::DoubleArray::result_type r[1024]; | |
chrono::time_point<chrono::system_clock> start, end; | |
start = chrono::system_clock::now(); | |
while (infile.getline (uuid, 1024)) { | |
size_t result = da.commonPrefixSearch(uuid, r, 1024); | |
if (result == 0) { | |
cout << "Not found" << endl; | |
return -1; | |
} | |
else { | |
// cout << "Found" << endl; | |
} | |
} | |
end = chrono::system_clock::now(); | |
chrono::duration<double> elapsed_seconds = end - start; | |
cout << "Duration: " << elapsed_seconds.count() << " s" << endl; | |
return 0; | |
} | |
/* | |
[komamitsu@potato tmp]$ ls -lh /Users/komamitsu/src/dart/darts-0.32/uuids.da | |
-rw-r--r-- 1 komamitsu staff 266M May 24 22:49 /Users/komamitsu/src/dart/darts-0.32/uuids.da | |
[komamitsu@potato tmp]$ wc -l /Users/komamitsu/tmp/uuids | |
1000000 /Users/komamitsu/tmp/uuids | |
[komamitsu@potato tmp]$ time ./dartest | |
Duration: 1.18769 s | |
real 0m1.392s | |
user 0m1.147s | |
sys 0m0.218s | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment