From d76fd5b7666cd1e7b9ff4eb51a822e1ab41fac28 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 29 Apr 2010 16:14:50 +0200 Subject: Separated benchmark from testcase --- all_benchmarks.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 all_benchmarks.py (limited to 'all_benchmarks.py') diff --git a/all_benchmarks.py b/all_benchmarks.py new file mode 100755 index 00000000..c03d0d92 --- /dev/null +++ b/all_benchmarks.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +"""Run all the tests inside the test/ directory as a test suite.""" +if __name__ == '__main__': + from test import * + from time import time + from types import FunctionType as function + from sys import argv + bms = [] + try: + n = int(argv[1]) + except IndexError: + n = 10 + for key, val in vars().copy().items(): + if key.startswith('bm_'): + bms.extend(v for k,v in vars(val).items() if type(v) == type) + for bmclass in bms: + for attrname in vars(bmclass): + if not attrname.startswith('bm_'): + continue + bmobj = bmclass() + t1 = time() + method = getattr(bmobj, attrname) + methodname = "{0}.{1}".format(bmobj.__class__.__name__, method.__name__) + try: + method(n) + except: + print("{0} failed!".format(methodname)) + raise + else: + t2 = time() + print("{0:60}: {1:10}s".format(methodname, t2 - t1)) -- cgit 1.4.1-2-gfad0 From da440d3a10b7ab05e9b55968344fff2cbc45da09 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 4 May 2010 00:06:25 +0200 Subject: Added license header to a few files --- Makefile | 15 +++++++++++++++ all_benchmarks.py | 15 +++++++++++++++ all_tests.py | 15 +++++++++++++++ test/bm_loader.py | 15 +++++++++++++++ 4 files changed, 60 insertions(+) (limited to 'all_benchmarks.py') diff --git a/Makefile b/Makefile index ffa81797..3b429367 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,18 @@ +# Copyright (C) 2009, 2010 Roman Zimbelmann +# +# This program 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. +# +# This program 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 this program. If not, see . + NAME = ranger VERSION = 1.0.4 PYTHON ?= python diff --git a/all_benchmarks.py b/all_benchmarks.py index c03d0d92..abcd051e 100755 --- a/all_benchmarks.py +++ b/all_benchmarks.py @@ -1,4 +1,19 @@ #!/usr/bin/python +# Copyright (C) 2009, 2010 Roman Zimbelmann +# +# This program 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. +# +# This program 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 this program. If not, see . + """Run all the tests inside the test/ directory as a test suite.""" if __name__ == '__main__': from test import * diff --git a/all_tests.py b/all_tests.py index 6693b870..90926918 100755 --- a/all_tests.py +++ b/all_tests.py @@ -1,4 +1,19 @@ #!/usr/bin/python +# Copyright (C) 2009, 2010 Roman Zimbelmann +# +# This program 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. +# +# This program 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 this program. If not, see . + """Run all the tests inside the test/ directory as a test suite.""" if __name__ == '__main__': import unittest diff --git a/test/bm_loader.py b/test/bm_loader.py index 33011108..0604d5ad 100644 --- a/test/bm_loader.py +++ b/test/bm_loader.py @@ -1,3 +1,18 @@ +# Copyright (C) 2009, 2010 Roman Zimbelmann +# +# This program 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. +# +# This program 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 this program. If not, see . + from ranger.core.loader import Loader from ranger.fsobject import Directory, File from ranger.ext.openstruct import OpenStruct -- cgit 1.4.1-2-gfad0 From a0e543f8b2adb7afb2822122d786f25b41f08ba2 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 10 May 2010 10:34:48 +0200 Subject: all_benchmarks: improved --- all_benchmarks.py | 28 ++++++++++++++++++++-------- test/bm_loader.py | 2 -- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'all_benchmarks.py') diff --git a/all_benchmarks.py b/all_benchmarks.py index abcd051e..73316658 100755 --- a/all_benchmarks.py +++ b/all_benchmarks.py @@ -16,6 +16,7 @@ """Run all the tests inside the test/ directory as a test suite.""" if __name__ == '__main__': + from re import compile from test import * from time import time from types import FunctionType as function @@ -25,6 +26,16 @@ if __name__ == '__main__': n = int(argv[1]) except IndexError: n = 10 + if len(argv) > 2: + args = [compile(re) for re in argv[2:]] + def allow(name): + for re in args: + if re.search(name): + return True + else: + return False + else: + allow = lambda name: True for key, val in vars().copy().items(): if key.startswith('bm_'): bms.extend(v for k,v in vars(val).items() if type(v) == type) @@ -36,11 +47,12 @@ if __name__ == '__main__': t1 = time() method = getattr(bmobj, attrname) methodname = "{0}.{1}".format(bmobj.__class__.__name__, method.__name__) - try: - method(n) - except: - print("{0} failed!".format(methodname)) - raise - else: - t2 = time() - print("{0:60}: {1:10}s".format(methodname, t2 - t1)) + if allow(methodname): + try: + method(n) + except: + print("{0} failed!".format(methodname)) + raise + else: + t2 = time() + print("{0:60}: {1:10}s".format(methodname, t2 - t1)) diff --git a/test/bm_loader.py b/test/bm_loader.py index 154fea3d..4bfc2db9 100644 --- a/test/bm_loader.py +++ b/test/bm_loader.py @@ -127,7 +127,6 @@ class benchmark_load(object): self.loader.work() -@skip class benchmark_raw_load(object): def __init__(self): SettingsAware.settings = Fake() @@ -143,7 +142,6 @@ def bm_loader(n): tloader = benchmark_load(N) traw = benchmark_raw_load(N) -@skip class benchmark_load_varieties(object): def bm_ls(self, n): for _ in range(n): -- cgit 1.4.1-2-gfad0