Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add benchmark suite using vbench

  • Loading branch information...
commit 23c3be1d4c6ac82997f249248aa36598cee29b5a 1 parent 97be0c1
@tkf authored
Showing with 66 additions and 0 deletions.
  1. +2 −0  .gitignore
  2. +7 −0 benchmark/run.sh
  3. +57 −0 benchmark/run_benchmark.py
View
2  .gitignore
@@ -1,3 +1,5 @@
MANIFEST
.tox
doc/build
+tmp
+benchmark/benchmarks.db
View
7 benchmark/run.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+cd $(dirname $0)/..
+vbench_dir=$(pwd)/lib/vbench
+export PYTHONPATH=$PYTHONPATH:$vbench_dir
+
+python benchmark/run_benchmark.py
View
57 benchmark/run_benchmark.py
@@ -0,0 +1,57 @@
+import os
+from datetime import datetime
+
+from vbench.api import Benchmark, BenchmarkRunner
+
+START_DATE = datetime(2012, 11, 20)
+
+common_setup = """
+import sexpdata
+length = 10000
+"""
+do_loads = 'sexpdata.loads(string)'
+
+benchmarks = [
+ Benchmark(
+ do_loads,
+ common_setup + r"""
+string = '"{0}"'.format('x' * length)
+""",
+ name="Plain long string (plain:quote = 1:0)",
+ start_date=START_DATE),
+ Benchmark(
+ do_loads,
+ common_setup + r"""
+string = '"{0}"'.format('\"' * length)
+""",
+ name="Long string only with escaped quotes (plain:quote = 0:1)",
+ start_date=START_DATE),
+ Benchmark(
+ do_loads,
+ common_setup + r"""
+string = '"{0}"'.format('1\"' * length)
+""",
+ name="Long mixed string (plain:quote = 1:1)",
+ start_date=START_DATE),
+ Benchmark(
+ do_loads,
+ common_setup + r"""
+string = '"{0}"'.format('12345\"' * length)
+""",
+ name="Long mixed string (plain:quote = 5:1)",
+ start_date=START_DATE),
+]
+
+bench_path = os.path.dirname(os.path.abspath(__file__))
+REPO_PATH = os.path.dirname(bench_path)
+REPO_URL = 'git@github.com:tkf/sexpdata.git'
+DB_PATH = os.path.join(bench_path, 'benchmarks.db')
+TMP_DIR = os.path.join(REPO_PATH, 'tmp', 'vb')
+PREPARE = ''
+
+BUILD = ''
+
+runner = BenchmarkRunner(benchmarks, REPO_PATH, REPO_URL,
+ BUILD, DB_PATH, TMP_DIR, PREPARE,
+ run_option='eod', start_date=START_DATE)
+runner.run()
Please sign in to comment.
Something went wrong with that request. Please try again.