Skip to content

Instantly share code, notes, and snippets.

@komamitsu
Last active May 24, 2017
Embed
What would you like to do?
// 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