mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-14 18:48:36 -07:00
RethinkDB native connector work, minor fixes.
This commit is contained in:
parent
a6203ed038
commit
4e88c80a22
219 changed files with 33295 additions and 0 deletions
58
ext/librethinkdbxx/test/bench.cc
Normal file
58
ext/librethinkdbxx/test/bench.cc
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
#include <signal.h>
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <rethinkdb.h>
|
||||
|
||||
namespace R = RethinkDB;
|
||||
std::unique_ptr<R::Connection> conn;
|
||||
|
||||
int main() {
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
try {
|
||||
conn = R::connect();
|
||||
} catch(const R::Error& error) {
|
||||
printf("FAILURE: could not connect to localhost:28015: %s\n", error.message.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
printf("running test...\n");
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
R::Datum d = R::range(1, 1000000)
|
||||
.map([]() { return R::object("test", "hello", "data", "world"); })
|
||||
.run(*conn);
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
auto diff = end - start;
|
||||
|
||||
printf("result size: %d\n", (int)d.get_array()->size());
|
||||
printf("completed in %f ms\n", std::chrono::duration<double, std::milli>(diff).count());
|
||||
} catch (const R::Error& error) {
|
||||
printf("FAILURE: uncaught exception: %s\n", error.message.c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <rethinkdb.h>
|
||||
|
||||
namespace R = RethinkDB;
|
||||
|
||||
int main() {
|
||||
auto conn = R::connect();
|
||||
if (!conn) {
|
||||
std::cerr << "Could not connect to server\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Connected" << std::endl;
|
||||
R::Cursor databases = R::db_list().run(*conn);
|
||||
for (R::Datum const& db : databases) {
|
||||
std::cout << *db.get_string() << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue