From patchwork Thu Sep 22 10:52:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 4256 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CD70023F98 for ; Thu, 22 Sep 2011 11:02:45 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id B803BA184A0 for ; Thu, 22 Sep 2011 11:02:45 +0000 (UTC) Received: by fxe23 with SMTP id 23so3668695fxe.11 for ; Thu, 22 Sep 2011 04:02:45 -0700 (PDT) Received: by 10.223.5.76 with SMTP id 12mr2831242fau.103.1316689365573; Thu, 22 Sep 2011 04:02:45 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.18.198 with SMTP id y6cs164085lad; Thu, 22 Sep 2011 04:02:45 -0700 (PDT) Received: by 10.227.206.83 with SMTP id ft19mr1952358wbb.112.1316688736398; Thu, 22 Sep 2011 03:52:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id er15si6698653wbb.57.2011.09.22.03.52.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Sep 2011 03:52:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1R6gt5-00013A-Re for ; Thu, 22 Sep 2011 10:52:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id C7DAFE1837 for ; Thu, 22 Sep 2011 10:52:15 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 140 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 140: Main, Options: Add support for loading the list of benchmark to run from a file. Message-Id: <20110922105215.18991.5611.launchpad@ackee.canonical.com> Date: Thu, 22 Sep 2011 10:52:15 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13996"; Instance="initZopeless config overlay" X-Launchpad-Hash: aa66ac8ae375fb2c0e0a29c446f3280d890f2141 ------------------------------------------------------------ revno: 140 committer: Alexandros Frantzis branch nick: trunk timestamp: Tue 2011-09-20 15:52:21 +0300 message: Main,Options: Add support for loading the list of benchmark to run from a file. modified: src/main.cpp src/options.cpp src/options.h --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/main.cpp' --- src/main.cpp 2011-09-12 16:08:24 +0000 +++ src/main.cpp 2011-09-20 12:52:21 +0000 @@ -29,6 +29,7 @@ #include "util.h" #include +#include #if USE_GL #include "canvas-x11-glx.h" @@ -85,6 +86,31 @@ } void +add_custom_benchmarks_from_files(vector &benchmarks) +{ + for (vector::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& scenes, Canvas& canvas) { scenes.push_back(new SceneDefaultOptions(canvas)); @@ -263,10 +289,12 @@ // Add the benchmarks to run vector 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' --- src/options.cpp 2011-09-20 09:45:24 +0000 +++ src/options.cpp 2011-09-20 12:52:21 +0000 @@ -32,6 +32,7 @@ #include "log.h" std::vector Options::benchmarks; +std::vector Options::benchmark_files; bool Options::validate = false; bool Options::swap_buffers = true; std::pair 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' --- src/options.h 2011-09-20 09:45:24 +0000 +++ src/options.h 2011-09-20 12:52:21 +0000 @@ -32,6 +32,7 @@ static void print_help(); static std::vector benchmarks; + static std::vector benchmark_files; static bool validate; static bool swap_buffers; static std::pair size;