Commit 4fefa4e0 authored by Dylan Baker's avatar Dylan Baker

Use simplejson if available

simplejson is a native code version of the json module in python
(the json module in core python implements the simplejson api), which
means that simplejson can be used in place of the json module, but it
performs much better. This patch attempts to load simplejson, and falls
back to normal json if it fails.

In the summary path on a single run of quick.tests, simplejson is about
3-4 seconds faster than json, ~7 seconds vs ~11 seconds.
Signed-off-by: Dylan Baker's avatarDylan Baker <baker.dylan.c@gmail.com>
parent e2db7519
......@@ -23,7 +23,6 @@
# Piglit core
import errno
import json
import os
import platform
import re
......@@ -39,6 +38,10 @@ from textwrap import dedent
from threads import synchronized_self
import threading
import multiprocessing
try:
import simplejson as json
except ImportError:
import json
from threadpool import ThreadPool
......
......@@ -23,7 +23,10 @@
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import json
try:
import simplejson as json
except ImportError:
import json
import os
import os.path
import os.path as path
......
......@@ -24,11 +24,14 @@
import os
import os.path as path
import json
import unittest
import itertools
import tempfile
try:
import simplejson as json
except ImportError:
import json
import framework.summary as summary
from helpers import test_iterations, create_testresult, create_test
......
......@@ -118,9 +118,12 @@
import collections
import csv
import json
import re
import sys
try:
import simplejson as json
except ImportError:
import json
GLSPEC_HEADER_REGEXP = re.compile(r'^(\w+)\((.*)\)$')
......
......@@ -28,7 +28,6 @@ import os
import os.path as path
import time
import traceback
import json
sys.path.append(path.dirname(path.realpath(sys.argv[0])))
import framework.core as core
......
......@@ -28,7 +28,6 @@ import os
import os.path as path
import time
import traceback
import json
sys.path.append(path.dirname(path.realpath(sys.argv[0])))
import framework.core as core
......
......@@ -143,9 +143,12 @@
# function corresponding to each entry in function_names.
import collections
import json
import os.path
import sys
try:
import simplejson as json
except:
import json
# Generate a top-of-file comment cautioning that the file is
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment