From d74de7f575a9ec49f96138c3c5251f28946c0c0e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 24 Nov 2018 13:44:02 +0100 Subject: Squashed 'waflib/' changes from 6e726eb..5ea8f99 5ea8f99 Improve test output spacing 0e23b29 Raise exception when test suite fails to ensure non-zero exit status d6de073 Show run time of unit tests 5b65554 Add short configure option for ultra-strict flags 4687ba6 Use gtest-like test output 258903d Fix failure count in test group summaries da07e73 Fix verbose tests with Python 3 git-subtree-dir: waflib git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d --- src/ganv_bench.cpp | 178 ----------------------------------------------------- 1 file changed, 178 deletions(-) delete mode 100644 src/ganv_bench.cpp (limited to 'src/ganv_bench.cpp') diff --git a/src/ganv_bench.cpp b/src/ganv_bench.cpp deleted file mode 100644 index b1bdefb..0000000 --- a/src/ganv_bench.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* This file is part of Ganv. - * Copyright 2013 David Robillard - * - * Ganv 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 any later version. - * - * Ganv 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 details. - * - * You should have received a copy of the GNU General Public License along - * with Ganv. If not, see . - */ - -#include -#include -#include - -#include -#include -#include -#include - -#include "ganv/ganv.hpp" - -using namespace std; -using namespace Ganv; - -static const int MAX_NUM_PORTS = 16; - -vector ins; -vector outs; - -static Module* -make_module(Canvas* canvas) -{ - char name[8]; - - snprintf(name, 8, "mod%d", rand() % 10000); - Module* m(new Module(*canvas, name, - rand() % (int)canvas->get_width(), - rand() % (int)canvas->get_height(), - true)); - - int n_ins = rand() % MAX_NUM_PORTS; - for (int i = 0; i < n_ins; ++i) { - snprintf(name, 8, "in%d", rand() % 10000); - Port* p(new Port(*m, name, true, - ((rand() % 0xFFFFFF) << 8) | 0xFF)); - ins.push_back(p); - } - - int n_outs = rand() % MAX_NUM_PORTS; - for (int i = 0; i < n_outs; ++i) { - snprintf(name, 8, "out%d", rand() % 10000); - Port* p(new Port(*m, name, false, - ((rand() % 0xFFFFFF) << 8) | 0xFF)); - outs.push_back(p); - } - - m->show(); - return m; -} - -static Circle* -make_circle(Canvas* canvas) -{ - char name[8]; - - snprintf(name, 8, "%d", rand() % 10000); - Circle* e(new Circle(*canvas, name, - rand() % (int)canvas->get_width(), - rand() % (int)canvas->get_height())); - - ins.push_back(e); - outs.push_back(e); - - return e; -} - -static bool -quit() -{ - Gtk::Main::quit(); - return true; -} - -static int -print_usage(const char* name) -{ - fprintf(stderr, - "USAGE: %s [OPTION]... CANVAS_W CANVAS_H N_MODULES N_CIRCLES N_EDGES\n\n" - "Options:\n" - " -o Remain open (do not close immediately)\n" - " -a Arrange canvas\n" - " -s Straight edges\n", - name); - return 1; -} - -int -main(int argc, char** argv) -{ - if (argc < 5) { - return print_usage(argv[0]); - } - - int arg = 1; - - bool remain_open = false; - bool arrange = false; - bool straight = false; - for (; arg < argc && argv[arg][0] == '-'; ++arg) { - if (argv[arg][1] == 'o') { - remain_open = true; - } else if (argv[arg][1] == 'a') { - arrange = true; - } else if (argv[arg][1] == 's') { - straight = true; - } else { - return print_usage(argv[0]); - } - } - - const int canvas_w = atoi(argv[arg++]); - const int canvas_h = atoi(argv[arg++]); - - if (argc - arg < 3) { - return print_usage(argv[0]); - } - - const int n_modules = atoi(argv[arg++]); - const int n_circles = atoi(argv[arg++]); - const int n_edges = atoi(argv[arg++]); - - srand(time(NULL)); - - Gtk::Main kit(argc, argv); - - Gtk::Window window; - Gtk::ScrolledWindow* scroller = Gtk::manage(new Gtk::ScrolledWindow()); - - Canvas* canvas = new Canvas(canvas_w, canvas_h); - scroller->add(canvas->widget()); - window.add(*scroller); - - window.show_all(); - - for (int i = 0; i < n_modules; ++i) { - make_module(canvas); - } - - for (int i = 0; i < n_circles; ++i) { - make_circle(canvas); - } - - for (int i = 0; i < n_edges; ++i) { - Node* src = outs[rand() % outs.size()]; - Node* dst = ins[rand() % ins.size()]; - Edge* c = new Edge(*canvas, src, dst, 0x808080FF); - if (straight) { - c->set_curved(false); - } - } - - if (arrange) { - canvas->arrange(); - } - - if (!remain_open) { - Glib::signal_idle().connect(sigc::ptr_fun(quit)); - } - - Gtk::Main::run(window); - - return 0; -} -- cgit v1.2.1