Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
7bddf0c5
Commit
7bddf0c5
authored
Dec 29, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressed issue #75: "Rudimentary benchmarking"
Usage: tests/benchmark.py 10000
parent
7e0270b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
tests/benchmark.py
+60
-0
No files found.
tests/benchmark.py
0 → 100755
View file @
7bddf0c5
#!/usr/bin/env python
# coding: utf-8
"""
A rudimentary backward- and forward-compatible script to benchmark pystache.
Usage:
tests/benchmark.py 10000
"""
import
sys
from
timeit
import
Timer
import
pystache
# TODO: make the example realistic.
examples
=
[
# Test case: 1
(
"""
\
{{#person}}Hi {{name}}{{/person}}"""
,
{
"person"
:
{
"name"
:
"Jon"
}},
"Hi Jon"
),
]
def
make_test_function
(
example
):
template
,
context
,
expected
=
example
def
test
():
actual
=
pystache
.
render
(
template
,
context
)
if
actual
!=
expected
:
raise
Exception
(
"Benchmark mismatch"
)
return
test
def
main
(
sys_argv
):
args
=
sys_argv
[
1
:]
count
=
int
(
args
[
0
])
print
"Benchmarking:
%
sx"
%
count
print
for
example
in
examples
:
test
=
make_test_function
(
example
)
t
=
Timer
(
test
,)
print
min
(
t
.
repeat
(
repeat
=
3
,
number
=
count
))
print
"Done"
if
__name__
==
'__main__'
:
main
(
sys
.
argv
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment