diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vbench/src/apps |
Publish
Diffstat (limited to 'vbench/src/apps')
-rw-r--r-- | vbench/src/apps/dumpurl/.gitignore | 5 | ||||
-rw-r--r-- | vbench/src/apps/dumpurl/CMakeLists.txt | 8 | ||||
-rw-r--r-- | vbench/src/apps/dumpurl/dumpurl.cpp | 43 | ||||
-rw-r--r-- | vbench/src/apps/vbench/.gitignore | 4 | ||||
-rw-r--r-- | vbench/src/apps/vbench/CMakeLists.txt | 8 | ||||
-rw-r--r-- | vbench/src/apps/vbench/input.txt | 30 | ||||
-rwxr-xr-x | vbench/src/apps/vbench/run.sh | 3 | ||||
-rw-r--r-- | vbench/src/apps/vbench/vbench.cfg | 16 | ||||
-rw-r--r-- | vbench/src/apps/vbench/vbench.cpp | 81 |
9 files changed, 198 insertions, 0 deletions
diff --git a/vbench/src/apps/dumpurl/.gitignore b/vbench/src/apps/dumpurl/.gitignore new file mode 100644 index 00000000000..27d8a9f5901 --- /dev/null +++ b/vbench/src/apps/dumpurl/.gitignore @@ -0,0 +1,5 @@ +/.depend +/Makefile +/dumpurl +/out.* +vbench_dumpurl_app diff --git a/vbench/src/apps/dumpurl/CMakeLists.txt b/vbench/src/apps/dumpurl/CMakeLists.txt new file mode 100644 index 00000000000..00f00da47e8 --- /dev/null +++ b/vbench/src/apps/dumpurl/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +vespa_add_executable(vbench_dumpurl_app + SOURCES + dumpurl.cpp + INSTALL bin + DEPENDS + vbench +) diff --git a/vbench/src/apps/dumpurl/dumpurl.cpp b/vbench/src/apps/dumpurl/dumpurl.cpp new file mode 100644 index 00000000000..a3bbc9be714 --- /dev/null +++ b/vbench/src/apps/dumpurl/dumpurl.cpp @@ -0,0 +1,43 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/fastos/fastos.h> +#include <vbench/http/http_result_handler.h> +#include <vbench/http/server_spec.h> +#include <vbench/http/http_client.h> + +using namespace vbench; + +class App : public FastOS_Application +{ +public: + int Main(); +}; + +struct MyHttpHandler : public HttpResultHandler { + virtual void handleHeader(const string &name, const string &value) { + fprintf(stderr, "got header: '%s': '%s'\n", name.c_str(), value.c_str()); + } + virtual void handleContent(const Memory &data) { + fprintf(stderr, "got data: %zu bytes\n", data.size); + fwrite(data.data, 1, data.size, stdout); + } + virtual void handleFailure(const string &reason) { + fprintf(stderr, "got FAILURE: '%s'\n", reason.c_str()); + } +}; + +int +App::Main() +{ + if (_argc != 4) { + printf("usage: dumpurl <host> <port> <url>\n"); + return -1; + } + MyHttpHandler myHandler; + bool ok = HttpClient::fetch(ServerSpec(_argv[1], atoi(_argv[2])), _argv[3], myHandler); + return ok ? 0 : 1; +} + +int main(int argc, char **argv) { + App app; + return app.Entry(argc, argv); +} diff --git a/vbench/src/apps/vbench/.gitignore b/vbench/src/apps/vbench/.gitignore new file mode 100644 index 00000000000..6df0c28e125 --- /dev/null +++ b/vbench/src/apps/vbench/.gitignore @@ -0,0 +1,4 @@ +/.depend +/Makefile +/vbench +vbench_app diff --git a/vbench/src/apps/vbench/CMakeLists.txt b/vbench/src/apps/vbench/CMakeLists.txt new file mode 100644 index 00000000000..5c9e423db3c --- /dev/null +++ b/vbench/src/apps/vbench/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +vespa_add_executable(vbench_app + SOURCES + vbench.cpp + INSTALL bin + DEPENDS + vbench +) diff --git a/vbench/src/apps/vbench/input.txt b/vbench/src/apps/vbench/input.txt new file mode 100644 index 00000000000..17b2919d56f --- /dev/null +++ b/vbench/src/apps/vbench/input.txt @@ -0,0 +1,30 @@ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ diff --git a/vbench/src/apps/vbench/run.sh b/vbench/src/apps/vbench/run.sh new file mode 100755 index 00000000000..0cd7abc3902 --- /dev/null +++ b/vbench/src/apps/vbench/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +env $(make ldl) ./vbench --input input.txt --qps 2 --host www.host.com --port 80 diff --git a/vbench/src/apps/vbench/vbench.cfg b/vbench/src/apps/vbench/vbench.cfg new file mode 100644 index 00000000000..88ceffd35b8 --- /dev/null +++ b/vbench/src/apps/vbench/vbench.cfg @@ -0,0 +1,16 @@ +{ + http_threads: 1000, + inputs: [ + { + source: { type: 'RequestGenerator', file: 'input.txt' }, + prepare: [ + { type: 'ServerTagger', host: 'www.host.com', port:80 }, + { type: 'QpsTagger', qps: 2 } + ] + } + ], + analyze: [ + { type: 'QpsAnalyzer' }, + { type: 'LatencyAnalyzer' } + ] +} diff --git a/vbench/src/apps/vbench/vbench.cpp b/vbench/src/apps/vbench/vbench.cpp new file mode 100644 index 00000000000..614856cd18c --- /dev/null +++ b/vbench/src/apps/vbench/vbench.cpp @@ -0,0 +1,81 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/fastos/fastos.h> +#include <vespa/vespalib/util/signalhandler.h> +#include <vespa/vespalib/util/programoptions.h> +#include <vespa/vespalib/util/sync.h> +#include <vespa/vespalib/util/thread.h> +#include <vespa/vespalib/util/runnable_pair.h> +#include <vbench/vbench/vbench.h> +#include <vespa/vespalib/data/slime/slime.h> +#include <string> +#include <iostream> + +using namespace vbench; + +typedef vespalib::SignalHandler SIG; + +struct NotifyDone : public vespalib::Runnable { + vespalib::Gate &done; + NotifyDone(vespalib::Gate &d) : done(d) {} + virtual void run() { + done.countDown(); + } +}; + +void setupSignals() { + SIG::PIPE.ignore(); + SIG::INT.hook(); + SIG::TERM.hook(); +} + +int run(const std::string &cfg_name) { + MappedFileInput cfg_file(cfg_name); + if (cfg_file.tainted()) { + fprintf(stderr, "could not load config file: %s\n", + cfg_file.tainted().reason().c_str()); + return 1; + } + vespalib::Slime cfg; + vespalib::slime::Memory mapped_cfg(cfg_file.get().data, + cfg_file.get().size); + if (!vespalib::slime::JsonFormat::decode(mapped_cfg, cfg)) { + fprintf(stderr, "unable to parse config file: %s\n", + cfg.toString().c_str()); + return 1; + } + setupSignals(); + vespalib::Gate done; + VBench vbench(cfg); + NotifyDone notify(done); + vespalib::RunnablePair runBoth(vbench, notify); + vespalib::Thread thread(runBoth); + thread.start(); + while (!SIG::INT.check() && !SIG::TERM.check() && !done.await(1000)) {} + if (!done.await(0)) { + vbench.abort(); + done.await(); + } + if (vbench.tainted()) { + fprintf(stderr, "vbench failed: %s\n", + vbench.tainted().reason().c_str()); + return 1; + } + return 0; +} + +int usage(const char *prog) { + fprintf(stderr, "vbench -- vespa benchmarking tool\n\n"); + fprintf(stderr, "usage: %s run <config-file>\n", prog); + fprintf(stderr, " run benchmarking as described in the config file.\n\n"); + return 1; +} + +int main(int argc, char **argv) { + if (argc > 1) { + std::string mode = argv[1]; + if (mode == "run" && argc == 3) { + return run(argv[2]); + } + } + return usage(argv[0]); +} |