=== modified file 'src/main.cpp'
@@ -29,6 +29,7 @@
#include "util.h"
#include <iostream>
+#include <fstream>
#if USE_GL
#include "canvas-x11-glx.h"
@@ -85,6 +86,31 @@
}
void
+add_custom_benchmarks_from_files(vector<Benchmark *> &benchmarks)
+{
+ for (vector<string>::const_iterator iter = Options::benchmark_files.begin();
+ iter != Options::benchmark_files.end();
+ iter++)
+ {
+ std::ifstream ifs(iter->c_str());
+
+ if (!ifs.fail()) {
+ std::string line;
+
+ while (getline(ifs, line)) {
+ if (!line.empty())
+ benchmarks.push_back(new Benchmark(line));
+ }
+ }
+ else {
+ Log::error("Cannot open benchmark file %s\n",
+ iter->c_str());
+ }
+
+ }
+}
+
+void
add_and_register_scenes(vector<Scene*>& scenes, Canvas& canvas)
{
scenes.push_back(new SceneDefaultOptions(canvas));
@@ -263,10 +289,12 @@
// Add the benchmarks to run
vector<Benchmark *> benchmarks;
- if (Options::benchmarks.empty())
+ if (!Options::benchmarks.empty())
+ add_custom_benchmarks(benchmarks);
+ else if (!Options::benchmark_files.empty())
+ add_custom_benchmarks_from_files(benchmarks);
+ else
add_default_benchmarks(benchmarks);
- else
- add_custom_benchmarks(benchmarks);
Log::info("=======================================================\n");
Log::info(" glmark2 %s\n", GLMARK_VERSION);
=== modified file 'src/options.cpp'
@@ -32,6 +32,7 @@
#include "log.h"
std::vector<std::string> Options::benchmarks;
+std::vector<std::string> Options::benchmark_files;
bool Options::validate = false;
bool Options::swap_buffers = true;
std::pair<int,int> Options::size(800, 600);
@@ -42,6 +43,7 @@
static struct option long_options[] = {
{"benchmark", 1, 0, 0},
+ {"benchmark-file", 1, 0, 0},
{"validate", 0, 0, 0},
{"no-swap-buffers", 0, 0, 0},
{"size", 1, 0, 0},
@@ -88,6 +90,8 @@
"Options:\n"
" -b, --benchmark BENCH A benchmark to run: 'scene(:opt1=val1)*'\n"
" (the option can be used multiple times)\n"
+ " -f, --benchmark-file F Load benchmarks to run from a file containing a\n"
+ " list of benchmark descriptions (one per line)"
" --validate Run a quick output validation test instead of \n"
" running the benchmarks\n"
" --no-swap-buffers Don't update the canvas by swapping the front and\n"
@@ -109,7 +113,7 @@
int c;
const char *optname = "";
- c = getopt_long(argc, argv, "b:s:ldh",
+ c = getopt_long(argc, argv, "b:f:s:ldh",
long_options, &option_index);
if (c == -1)
break;
@@ -121,6 +125,8 @@
if (c == 'b' || !strcmp(optname, "benchmark"))
Options::benchmarks.push_back(optarg);
+ else if (c == 'f' || !strcmp(optname, "benchmark-file"))
+ Options::benchmark_files.push_back(optarg);
else if (!strcmp(optname, "validate"))
Options::validate = true;
else if (!strcmp(optname, "no-swap-buffers"))
=== modified file 'src/options.h'
@@ -32,6 +32,7 @@
static void print_help();
static std::vector<std::string> benchmarks;
+ static std::vector<std::string> benchmark_files;
static bool validate;
static bool swap_buffers;
static std::pair<int,int> size;