Ticket #1857 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

buildbot.util should prefer simplejson over built-in json

Reported by: catlee Owned by:
Priority: minor Milestone: 0.8.4
Version: 0.8.3p1 Keywords:
Cc:

Description

Python 2.6's json is significantly slower than simplejson.

import json
import simplejson
import time

def task(module, data):
    encoded = module.dumps(data)
    orig = module.loads(encoded)
    assert data == orig

n = 1000

data = {}
for i in range(100):
    data[str(i)] = "hello" * i

for module in json, simplejson:
    s = time.time()
    for i in range(n):
        task(module, data)
    e = time.time()
    print module.__name__, e-s

outputs

json 1.52023100853
simplejson 0.200721979141

on my system with python 2.6.6.

Python 2.7 is much improved:

json 0.206233024597
simplejson 0.189265012741

Buildbot should prefer simplejson for python <= 2.6.

Change History

comment:1 Changed 2 years ago by catlee

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from undecided to 0.8.4

Fixed by d97698c393aa0894c47369266c3f726280f2c96b

Note: See TracTickets for help on using tickets.