mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 19:35:12 +00:00
This is a test that allow us to query the performance of our sstable index reads and writes (currently only writes implemented). A lot of potentially common code is put into a header, which will make writing new tests easier if needed. We don't want to take shortcuts for this, so all reading and writing is done through public sstable interfaces. For writing, there is no way to write the index without writing the datafile. But because we are only writing the primary key, the datafile will not contain anything else. This is the closest we can get to an index testing with the public interfaces. Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
#include <core/distributed.hh>
|
|
#include <core/app-template.hh>
|
|
#include <core/sstring.hh>
|
|
#include <random>
|
|
#include "perf_sstable.hh"
|
|
|
|
using namespace sstables;
|
|
|
|
static unsigned iterations = 30;
|
|
|
|
future<> test_write(distributed<test_env>& dt) {
|
|
return dt.invoke_on_all([] (test_env &t) {
|
|
t.fill_memtable();
|
|
}).then([&dt] {
|
|
return time_runs(iterations, dt, &test_env::flush_memtable);
|
|
});
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
namespace bpo = boost::program_options;
|
|
app_template app;
|
|
app.add_options()
|
|
("iterations", bpo::value<unsigned>()->default_value(30), "number of iterations")
|
|
("partitions", bpo::value<unsigned>()->default_value(5000000), "number of partitions")
|
|
("key_size", bpo::value<unsigned>()->default_value(128), "size of partition key")
|
|
("testdir", bpo::value<sstring>()->default_value("/var/lib/cassandra/perf-tests"), "directory in which to store the sstables");
|
|
|
|
return app.run(argc, argv, [&app] {
|
|
auto test = make_lw_shared<distributed<test_env>>();
|
|
|
|
auto cfg = test_env::conf();
|
|
iterations = app.configuration()["iterations"].as<unsigned>();
|
|
cfg.partitions = app.configuration()["partitions"].as<unsigned>();
|
|
cfg.key_size = app.configuration()["key_size"].as<unsigned>();
|
|
sstring dir = app.configuration()["testdir"].as<sstring>();
|
|
cfg.dir = dir;
|
|
return test->start(std::move(cfg)).then([dir, test] {
|
|
engine().at_exit([test] { return test->stop(); });
|
|
return test_setup::create_empty_test_dir(dir);
|
|
}).then([test] {
|
|
return test_write(*test).then([test] {});
|
|
}).then([] {
|
|
return engine().exit(0);
|
|
}).or_terminate();
|
|
});
|
|
}
|