From patchwork Thu Jun 23 14:23:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 2222 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 7A14023F6D for ; Thu, 23 Jun 2011 14:28:31 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 36991A189BA for ; Thu, 23 Jun 2011 14:28:31 +0000 (UTC) Received: by qyk30 with SMTP id 30so1376426qyk.11 for ; Thu, 23 Jun 2011 07:28:30 -0700 (PDT) Received: by 10.229.137.149 with SMTP id w21mr1631315qct.59.1308839310677; Thu, 23 Jun 2011 07:28:30 -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.229.230.139 with SMTP id jm11cs19433qcb; Thu, 23 Jun 2011 07:28:30 -0700 (PDT) Received: by 10.216.140.146 with SMTP id e18mr167595wej.27.1308838996662; Thu, 23 Jun 2011 07:23:16 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id 7si3847919wem.146.2011.06.23.07.23.16; Thu, 23 Jun 2011 07:23:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QZkoN-0003mW-GI for ; Thu, 23 Jun 2011 14:23:15 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 7A5702E8060 for ; Thu, 23 Jun 2011 14:23:15 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glcompbench X-Launchpad-Branch: ~glcompbench-dev/glcompbench/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 34 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 34: Add special CompositeTestDefaultOptions class used for changing default options at runtime. Message-Id: <20110623142315.3922.63077.launchpad@loganberry.canonical.com> Date: Thu, 23 Jun 2011 14:23: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="13265"; Instance="initZopeless config overlay" X-Launchpad-Hash: cf6d816f3bd7f8bec9cb32a455aff3720e509956 ------------------------------------------------------------ revno: 34 committer: Alexandros Frantzis branch nick: trunk timestamp: Thu 2011-06-23 16:52:16 +0300 message: Add special CompositeTestDefaultOptions class used for changing default options at runtime. added: src/composite-test-default-options.cc modified: src/composite-canvas.cc src/composite-test.cc src/composite-test.h src/glcompbench.cc --- lp:glcompbench https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk You are subscribed to branch lp:glcompbench. To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription === modified file 'src/composite-canvas.cc' --- src/composite-canvas.cc 2011-06-23 13:32:36 +0000 +++ src/composite-canvas.cc 2011-06-23 13:52:16 +0000 @@ -595,29 +595,32 @@ { Benchmark *benchmark = *benchIt; current_test_ = &benchmark->setup_test(); - load_current_test_options(); - reshape(width_, height_); - Log::info("Running test: '%s'\n", current_test_->name().c_str()); - - while (true) { - if (handle_xevent()) { - if (Options::force_tex_update) - update_all_textures(); - - if (Options::draw) { - profiler_draw_pair_.sample_start(); - current_test_->draw(this->window_list_); - profiler_draw_pair_.sample_end(); - profiler_screen_update_pair_.sample_start(); - update_screen(); - profiler_screen_update_pair_.sample_end(); - } - - benchmark_update(next_iteration); - if (next_iteration) { - break; - } - + + if (!current_test_->name().empty()) { + load_current_test_options(); + reshape(width_, height_); + Log::info("Running test: '%s'\n", current_test_->name().c_str()); + + while (true) { + if (handle_xevent()) { + if (Options::force_tex_update) + update_all_textures(); + + if (Options::draw) { + profiler_draw_pair_.sample_start(); + current_test_->draw(this->window_list_); + profiler_draw_pair_.sample_end(); + profiler_screen_update_pair_.sample_start(); + update_screen(); + profiler_screen_update_pair_.sample_end(); + } + + benchmark_update(next_iteration); + if (next_iteration) { + break; + } + + } } } === added file 'src/composite-test-default-options.cc' --- src/composite-test-default-options.cc 1970-01-01 00:00:00 +0000 +++ src/composite-test-default-options.cc 2011-06-23 13:52:16 +0000 @@ -0,0 +1,55 @@ +/* + * Copyright © 2011 Linaro Limited + * + * This file is part of glcompbench. + * + * glcompbench is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * glcompbench is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with glcompbench. If not, see . + * + * Authors: + * Alexandros Frantzis + * Jesse Barker + */ + +#include "composite-test.h" +#include "options.h" +#include "benchmark.h" + +/** + * Prepares the test for a test run. + */ +void +CompositeTestDefaultOptions::prepare_for_run() +{ + const std::map &tests = Benchmark::tests(); + + for (std::list >::const_iterator iter = default_options_.begin(); + iter != default_options_.end(); + iter++) + { + for (std::map::const_iterator test_iter = tests.begin(); + test_iter != tests.end(); + test_iter++) + { + test_iter->second->set_option_default(iter->first, iter->second); + } + } +} + +bool +CompositeTestDefaultOptions::set_option(const std::string &opt, + const std::string &val) +{ + default_options_.push_back(std::pair(opt, val)); + return true; +} === modified file 'src/composite-test.cc' --- src/composite-test.cc 2011-06-23 13:10:17 +0000 +++ src/composite-test.cc 2011-06-23 13:52:16 +0000 @@ -83,3 +83,15 @@ } } +bool +CompositeTest::set_option_default(const string &opt, const string &val) +{ + map::iterator iter = options_.find(opt); + + if (iter == options_.end()) + return false; + + iter->second.default_value = val; + + return true; +} === modified file 'src/composite-test.h' --- src/composite-test.h 2011-06-23 13:32:36 +0000 +++ src/composite-test.h 2011-06-23 13:52:16 +0000 @@ -63,8 +63,9 @@ std::string description; }; - bool set_option(const std::string &opt, const std::string &val); + virtual bool set_option(const std::string &opt, const std::string &val); void reset_options(); + bool set_option_default(const std::string &opt, const std::string &val); const std::map &options() { return options_; } static CompositeTest &dummy() @@ -87,6 +88,18 @@ std::map options_; }; +class CompositeTestDefaultOptions : public CompositeTest +{ +public: + CompositeTestDefaultOptions() : CompositeTest("") {} + + virtual void prepare_for_run(); + virtual bool set_option(const std::string &opt, const std::string &val); + +protected: + std::list > default_options_; +}; + class CompositeTestSimpleBase : public CompositeTest { public: === modified file 'src/glcompbench.cc' --- src/glcompbench.cc 2011-06-23 11:25:34 +0000 +++ src/glcompbench.cc 2011-06-23 13:52:16 +0000 @@ -50,6 +50,9 @@ test_iter++) { CompositeTest *test = test_iter->second; + if (test->name().empty()) + continue; + Log::info("[Test] %s\n", test->name().c_str()); const map &options = test->options(); @@ -107,6 +110,7 @@ return 0; } + Benchmark::register_test(*new CompositeTestDefaultOptions()); Benchmark::register_test(*new CompositeTestSimpleDefault()); Benchmark::register_test(*new CompositeTestSimpleBrick());