summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-01-03 12:29:16 +0100
committerJamey Hicks <jamey.hicks@nokia.com>2012-01-04 00:24:13 +0100
commit37b221755fb96512934f5688b70c45d62b34d005 (patch)
treeb7546004f8eee796ea48bc53d3706c2558a6967c
parent776da9081bcacc40c8c62247e8f045cb4e621297 (diff)
Add another benchmark
This adds the numbers benchmark also used by qjsonparser. Change-Id: I350c6a62a4cdebfa5105ebdf4bb1b00029c1ad70 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
-rw-r--r--tests/benchmarks/numbers.json19
-rw-r--r--tests/benchmarks/tst_bench_qtbinaryjson.cpp13
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/benchmarks/numbers.json b/tests/benchmarks/numbers.json
new file mode 100644
index 0000000..469156a
--- /dev/null
+++ b/tests/benchmarks/numbers.json
@@ -0,0 +1,19 @@
+[
+ {
+ "integer": 1234567890,
+ "real": -9876.543210,
+ "e": 0.123456789e-12,
+ "E": 1.234567890E+34,
+ "": 23456789012E66,
+ "zero": 0,
+ "one": 1
+ },
+ [
+ -1234567890,
+ -1234567890,
+ -1234567890,
+ 1234567890,
+ 1234567890,
+ 1234567890
+ ]
+]
diff --git a/tests/benchmarks/tst_bench_qtbinaryjson.cpp b/tests/benchmarks/tst_bench_qtbinaryjson.cpp
index 9066049..7ced384 100644
--- a/tests/benchmarks/tst_bench_qtbinaryjson.cpp
+++ b/tests/benchmarks/tst_bench_qtbinaryjson.cpp
@@ -54,6 +54,7 @@ private Q_SLOTS:
void init();
void cleanup();
+ void parseNumbers();
void parseJson();
void parseJsonToVariant();
};
@@ -83,6 +84,18 @@ void BenchmarkQtBinaryJson::cleanup()
}
+void BenchmarkQtBinaryJson::parseNumbers()
+{
+ QFile file(QLatin1String("numbers.json"));
+ file.open(QFile::ReadOnly);
+ QByteArray testJson = file.readAll();
+
+ QBENCHMARK {
+ JsonDocument doc = JsonDocument::fromJson(testJson);
+ JsonObject object = doc.object();
+ }
+}
+
void BenchmarkQtBinaryJson::parseJson()
{
QFile file(QLatin1String("../auto/test.json"));