Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from markupsafe import escape | ||
|
||
|
||
def run(): | ||
escape('<strong>Hello World!</strong>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from markupsafe import escape | ||
|
||
|
||
def run(): | ||
string = '<strong>Hello World!</strong>' * 1000 | ||
escape(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from markupsafe import escape | ||
|
||
|
||
def run(): | ||
string = 'Hello World!' * 1000 | ||
escape(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from markupsafe import escape | ||
|
||
|
||
def run(): | ||
string = '<strong>Hello World!</strong>' + 'x' * 100000 | ||
escape(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from markupsafe import escape | ||
|
||
|
||
def run(): | ||
escape('Hello World!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Runs the benchmarks | ||
""" | ||
import sys | ||
import os | ||
import re | ||
from subprocess import Popen | ||
|
||
_filename_re = re.compile(r'^bench_(.*?)\.py$') | ||
bench_directory = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
def list_benchmarks(): | ||
result = [] | ||
for name in os.listdir(bench_directory): | ||
match = _filename_re.match(name) | ||
if match is not None: | ||
result.append(match.group(1)) | ||
result.sort(key=lambda x: (x.startswith('logging_'), x.lower())) | ||
return result | ||
|
||
|
||
def run_bench(name): | ||
sys.stdout.write('%-32s' % name) | ||
sys.stdout.flush() | ||
Popen([sys.executable, '-mtimeit', '-s', | ||
'from bench_%s import run' % name, | ||
'run()']).wait() | ||
|
||
|
||
def main(): | ||
print '=' * 80 | ||
print 'Running benchmark for MarkupSafe' | ||
print '-' * 80 | ||
os.chdir(bench_directory) | ||
for bench in list_benchmarks(): | ||
run_bench(bench) | ||
print '-' * 80 | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |