diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-07-09 16:22:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-07-10 06:57:24 -0400 |
commit | 6b226d85f5191cd27b20ad27caded8b407772a02 (patch) | |
tree | a7d2e58246fb5ef9b8128ff342e97968c4ace853 /lab | |
parent | 9bc6b93805a5f20a87211a315d00503eddab66dc (diff) | |
download | python-coveragepy-git-6b226d85f5191cd27b20ad27caded8b407772a02.tar.gz |
Remove the JSON data code
Diffstat (limited to 'lab')
-rw-r--r-- | lab/gendata.py | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/lab/gendata.py b/lab/gendata.py deleted file mode 100644 index 27ad4fda..00000000 --- a/lab/gendata.py +++ /dev/null @@ -1,42 +0,0 @@ -# Run some timing tests of JsonData vs SqliteData. - -import random -import time - -from coverage.data import CoverageJsonData -from coverage.sqldata import CoverageSqliteData - -NUM_FILES = 1000 -NUM_LINES = 1000 - -def gen_data(cdata): - rnd = random.Random() - rnd.seed(17) - - def linenos(num_lines, prob): - return (n for n in range(num_lines) if random.random() < prob) - - start = time.time() - for i in range(NUM_FILES): - filename = "/src/foo/project/file{i}.py".format(i=i) - line_data = { filename: dict.fromkeys(linenos(NUM_LINES, .6)) } - cdata.add_lines(line_data) - - cdata.write() - end = time.time() - delta = end - start - return delta - -class DummyData: - def add_lines(self, line_data): - return - def write(self): - return - -overhead = gen_data(DummyData()) -jtime = gen_data(CoverageJsonData("gendata.json")) - overhead -stime = gen_data(CoverageSqliteData("gendata.db")) - overhead -print("Overhead: {overhead:.3f}s".format(overhead=overhead)) -print("JSON: {jtime:.3f}s".format(jtime=jtime)) -print("SQLite: {stime:.3f}s".format(stime=stime)) -print("{slower:.3f}x slower".format(slower=stime/jtime)) |