예제 #1
0
파일: perf.py 프로젝트: fjarri-attic/brain
def runPerformanceTests(verbosity=2):
	"""Start functionality tests suite"""

	print("Performance tests:")

	# folder for DBs which are represented by files
	db_path = tempfile.mkdtemp(prefix='braindb')

	test_suites = public.getEngineTestSuites(db_path)

	for test_suite in test_suites:
		test_time = helpers.TextTestRunner(verbosity=verbosity,
			show_report=False).run(test_suite)
		print("* Functionality tests: {0:.3f} s".format(test_time))

	total_times = None
	seeds = [100, 200, 300]
	for seed in seeds:
		if verbosity > 2:
			print("Running fuzz test for seed " + str(seed))
		times = fuzz.runFuzzTest(objects=5, seed=seed, show_report=False)
		if total_times is None:
			total_times = times
		else:
			for action in times:
				total_times[action] += times[action]

	time_strings = ["- " + action + ": {0:.3f} s".format(total_times[action])
		for action in total_times]
	print("* Fuzz test, seeds " + ", ".join([str(seed) for seed in seeds]) +
		", action times:\n" + "\n".join(time_strings))
예제 #2
0
파일: run.py 프로젝트: fjarri-attic/brain
# Parse options and run tests

if len(sys.argv) == 1:
    parser.error("Error: mode should be specified")

# FIXME: find a way to do it using OptionParser
modes = ["func", "fuzz", "doc", "perf"]
mode = sys.argv[1]
args = sys.argv[2:]

if mode not in modes:
    parser.print_help()
    sys.exit(1)

opts, args = parser.parse_args(args)

if mode == "func":
    func.runFunctionalityTests(
        all_connections=opts.all_connections,
        all_engines=opts.all_engines,
        all_storages=opts.all_storages,
        verbosity=opts.verbosity,
    )
elif mode == "fuzz":
    fuzz.runFuzzTest(objects=opts.objects, actions=opts.actions, seed=opts.seed, verbosity=opts.verbosity)
elif mode == "doc":
    doc.runDocTest(verbosity=opts.verbosity)
elif mode == "perf":
    perf.runPerformanceTests(verbosity=opts.verbosity)