allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [42/50] git commit: [#6686] move other performance testing scripts into scripts/perf/
Date Tue, 22 Oct 2013 15:01:09 GMT
[#6686] move other performance testing scripts into scripts/perf/


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/548b7328
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/548b7328
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/548b7328

Branch: refs/heads/cj/6692
Commit: 548b73286a5d55f374bc9a174902c6f8dc9f0ab2
Parents: d91c8ff
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Mon Oct 21 21:17:34 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Oct 21 21:17:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/scripts/md_perf.py | 130 -------------------------------
 scripts/benchmark-scm.py         | 143 ----------------------------------
 scripts/perf/benchmark-scm.py    | 143 ++++++++++++++++++++++++++++++++++
 scripts/perf/md_perf.py          | 130 +++++++++++++++++++++++++++++++
 scripts/perf/sstress.py          |  54 +++++++++++++
 scripts/sstress.py               |  54 -------------
 6 files changed, 327 insertions(+), 327 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/548b7328/Allura/allura/scripts/md_perf.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/md_perf.py b/Allura/allura/scripts/md_perf.py
deleted file mode 100644
index 708a296..0000000
--- a/Allura/allura/scripts/md_perf.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-"""
-A script for timing/profiling the Markdown conversion of an artifact discussion thread.
-
-Example usage:
-
-(env-allura)root@h1v1024:/var/local/allura/Allura(master)$ time paster script production.ini
allura/scripts/md_perf.py -- --converter=forge
-      Conversion Time (s)  Text Size Post._id
-   1 0.021863937377929688         20 7d3ce86bb2c3afaee21f28547ed542d0c8c483b8
-   2 0.002238035202026367         12 96b1283c6db619cd66ee092551758dc1ad5b958f
-   3 0.001832962036132812          9 42c44cd72815d29069378353745bef953bdb2b98
-   4 0.011796951293945312        901 cadbea52291c58bb190597c1df94527369b405fa
-   5 0.143218040466308594      11018 362bee7ef1ba4e062712bda22cb96ae9fe459b95
-   6 0.029596090316772461       1481 46b78785b849f55d24cf32ee1f4e4c916cb7a6fe
-   7 0.045151948928833008       4144 4e2f62188080baba9b88c045ba1f7c26903bfcf9
-   8 0.637056827545166016      14553 51c87f2b1d55c08147bb2353e20361236232b432
-   9 4.510329008102416992      23016 f298ad88584f3dc9b5c37ffde61391bf03d5bae6
-  10 3.614714860916137695      23016 8775a230b19c231daa1608bb4cea1e17aab54550
-  11 0.393079042434692383      19386 ed79e0d2f89366043a007e0837e98945453508c9
-  12 0.000739097595214844      43659 56ac2437ec1bd886a03d23e45aa1c947729760ec
-  13 0.258469104766845703       8520 57152cefe0424b7fc9dff7ab4d21a6ef6e90bf82
-  14 0.264052867889404297       8518 6788b13c90c9719ba46196a0a773f4c228df9f2a
-  15 0.995774984359741211      14553 3f5cce06d2400bcd56d7b90d12c569935f0099a4
-Total time: 10.930670023
-
-real    0m14.256s
-user    0m12.749s
-sys     0m1.112s
-
-"""
-
-import argparse
-import cProfile
-import re
-import sys
-import time
-
-from mock import patch
-
-try:
-    import re2
-    re2.set_fallback_notification(re2.FALLBACK_WARNING)
-    RE2_INSTALLED = True
-except ImportError:
-    RE2_INSTALLED = False
-
-from pylons import app_globals as g
-
-MAX_OUTPUT = 99999
-DUMMYTEXT = None
-
-
-def get_artifact():
-    from forgeblog import model as BM
-    return BM.BlogPost.query.get(
-            slug='2013/09/watch-breaking-bad-season-5-episode-16-felina-live-streaming')
-
-
-def main(opts):
-    import markdown
-    if opts.re2 and RE2_INSTALLED:
-        markdown.inlinepatterns.re = re2
-    converters = {
-        'markdown': lambda: markdown.Markdown(),
-        'markdown_safe': lambda: markdown.Markdown(safe_mode=True),
-        'markdown_escape': lambda: markdown.Markdown(safe_mode='escape'),
-        'forge': lambda: g.markdown,
-        }
-    md = converters[opts.converter]()
-    artifact = get_artifact()
-    return render(artifact, md, opts)
-
-
-def render(artifact, md, opts):
-    start = begin = time.time()
-    print "%4s %20s %10s %s" % ('', 'Conversion Time (s)', 'Text Size', 'Post._id')
-    for i, p in enumerate(artifact.discussion_thread.posts):
-        text = DUMMYTEXT or p.text
-        if opts.n and i + 1 not in opts.n:
-            print 'Skipping post %s' % str(i + 1)
-            continue
-        if opts.profile:
-            print 'Profiling post %s' % str(i + 1)
-            cProfile.runctx('output = md.convert(text)', globals(), locals())
-        else:
-            output = md.convert(text)
-        elapsed = time.time() - start
-        print "%4s %1.18f %10s %s" % (i + 1, elapsed, len(text), p._id)
-        if opts.output:
-            print 'Input:', text[:min(300, len(text))]
-            print 'Output:', output[:min(MAX_OUTPUT, len(output))]
-        start = time.time()
-    print "Total time:", start - begin
-    return output
-
-
-def parse_options():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--converter', default='markdown')
-    parser.add_argument('--profile', action='store_true', help='Run profiler and output timings')
-    parser.add_argument('--output', action='store_true', help='Print result of markdown conversion')
-    parser.add_argument('--re2', action='store_true', help='Run with re2 instead of re')
-    parser.add_argument('--compare', action='store_true', help='Run with re and re2, and
compare results')
-    parser.add_argument('-n', '--n', nargs='+', type=int, help='Only convert nth post(s)
in thread')
-    return parser.parse_args()
-
-
-if __name__ == '__main__':
-    opts = parse_options()
-    out1 = main(opts)
-    if opts.compare:
-        opts.re2 = not opts.re2
-        out2 = main(opts)
-        print 're/re2 outputs match: ', out1 == out2

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/548b7328/scripts/benchmark-scm.py
----------------------------------------------------------------------
diff --git a/scripts/benchmark-scm.py b/scripts/benchmark-scm.py
deleted file mode 100755
index 0a4e9eb..0000000
--- a/scripts/benchmark-scm.py
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/env python
-
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-
-import os
-import sys
-import argparse
-from datetime import datetime
-
-import git
-import pysvn
-from mercurial import ui, hg, cmdutil
-
-
-def main(opts):
-    if opts.type == 'git':
-        repo = git.Repo(opts.repo_path, odbt=git.GitCmdObjectDB)
-        cid = opts.cid
-        path = opts.path.strip('/')
-        tree = repo.commit(opts.cid).tree
-        if path:
-            tree = tree[path]
-        names = [n.name for n in tree]
-        impl = impl_git_tree if opts.full_tree else impl_git_node
-    elif opts.type == 'hg':
-        repo = hg.repository(HgUI(), opts.repo_path)
-        cid = None if opts.cid == 'HEAD' else ['%s:0' % opts.cid]
-        path = opts.path.strip('/')
-        filenames = repo['tip' if opts.cid == 'HEAD' else opts.cid].manifest().keys()
-        filenames = [name for name in filenames if name.startswith(('%s/' % path).lstrip('/'))]
-        names = set()
-        for name in filenames:
-            names.add(name.split('/')[0])
-        names = list(names)
-        impl = impl_hg_tree if opts.full_tree else impl_hg_node
-    elif opts.type == 'svn':
-        repo = pysvn.Client()
-        if opts.cid == 'HEAD':
-            cid = pysvn.Revision(pysvn.opt_revision_kind.head)
-        else:
-            cid = pysvn.Revision(pysvn.opt_revision_kind.number, opts.cid)
-        path = opts.path.strip('/')
-        names = []
-        impl = impl_svn_tree if opts.full_tree else impl_svn_node
-
-    sys.stdout.write('Timing %s' % ('full tree' if opts.full_tree else 'node'))
-    sys.stdout.flush()
-    total = 0.0
-    for i in range(opts.count):
-        sys.stdout.write('.')
-        sys.stdout.flush()
-        start = datetime.now()
-        impl(repo, cid, path, names, opts.repo_path)
-        end = datetime.now()
-        total += (end - start).total_seconds()
-    print
-    print 'Total time:           %s' % total
-    print 'Average time per run: %s' % (total / opts.count)
-
-
-def impl_git_tree(repo, cid, path, names, *args):
-    data = {}
-    for name in names:
-        #data[name] = repo.git.rev_list(cid, '--', os.path.join(path, name), max_count=1)
-        data[name] = git.Commit.iter_items(repo, cid, os.path.join(path, name), max_count=1).next().hexsha
-    return data
-
-def impl_git_node(repo, cid, path, *args):
-    #return repo.git.rev_list(cid, '--', path, max_count=1)
-    return git.Commit.iter_items(repo, cid, path, max_count=1).next().hexsha
-
-
-def impl_hg_tree(repo, cid, path, names, *args):
-    m = cmdutil.match(repo, pats=[path], default=path)
-    data = {}
-    for name in names:
-        rev_iter = cmdutil.walkchangerevs(repo, m, {'rev': cid}, lambda c,f: None)
-        data[name] = rev_iter.next().hex()
-    return data
-
-def impl_hg_node(repo, cid, path, *args):
-    m = cmdutil.match(repo, pats=[path], default=path)
-    rev_iter = cmdutil.walkchangerevs(repo, m, {'rev': cid}, lambda c,f: None)
-    return rev_iter.next().hex()
-
-def impl_svn_tree(repo, cid, path, names, repo_path, *args):
-    infos = repo.info2(
-            'file://%s/%s' % (repo_path, path),
-            revision=cid,
-            depth=pysvn.depth.immediates)
-    data = {}
-    for name, info in infos[1:]:
-        data[name] = info.last_changed_rev
-    return data
-
-def impl_svn_node(repo, cid, path, names, repo_path, *args):
-    logs = repo.log(
-            'file://%s/%s' % (repo_path, path),
-            revision_start=cid,
-            limit=1)
-    return logs[0].revision.number
-
-
-class HgUI(ui.ui):
-    '''Hg UI subclass that suppresses reporting of untrusted hgrc files.'''
-    def __init__(self, *args, **kwargs):
-        super(HgUI, self).__init__(*args, **kwargs)
-        self._reportuntrusted = False
-
-def parse_opts():
-    parser = argparse.ArgumentParser(description='Benchmark getting LCD from repo tool')
-    parser.add_argument('--type', default='git', dest='type',
-            help='Type of repository being tested.')
-    parser.add_argument('--repo-path', dest='repo_path', required=True,
-            help='Path to the repository to test against')
-    parser.add_argument('--commit', default='HEAD', dest='cid',
-            help='Commit ID or revision number to test against')
-    parser.add_argument('--path', default='', dest='path',
-            help='Path within the repository to test against')
-    parser.add_argument('--count', type=int, default=100, dest='count',
-            help='Number of times to execute')
-    parser.add_argument('--full-tree', action='store_true', default=False, dest='full_tree',
-            help='Time full tree listing instead of just the single node')
-    return parser.parse_args()
-
-if __name__ == '__main__':
-    main(parse_opts())

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/548b7328/scripts/perf/benchmark-scm.py
----------------------------------------------------------------------
diff --git a/scripts/perf/benchmark-scm.py b/scripts/perf/benchmark-scm.py
new file mode 100755
index 0000000..0a4e9eb
--- /dev/null
+++ b/scripts/perf/benchmark-scm.py
@@ -0,0 +1,143 @@
+#!/bin/env python
+
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+
+import os
+import sys
+import argparse
+from datetime import datetime
+
+import git
+import pysvn
+from mercurial import ui, hg, cmdutil
+
+
+def main(opts):
+    if opts.type == 'git':
+        repo = git.Repo(opts.repo_path, odbt=git.GitCmdObjectDB)
+        cid = opts.cid
+        path = opts.path.strip('/')
+        tree = repo.commit(opts.cid).tree
+        if path:
+            tree = tree[path]
+        names = [n.name for n in tree]
+        impl = impl_git_tree if opts.full_tree else impl_git_node
+    elif opts.type == 'hg':
+        repo = hg.repository(HgUI(), opts.repo_path)
+        cid = None if opts.cid == 'HEAD' else ['%s:0' % opts.cid]
+        path = opts.path.strip('/')
+        filenames = repo['tip' if opts.cid == 'HEAD' else opts.cid].manifest().keys()
+        filenames = [name for name in filenames if name.startswith(('%s/' % path).lstrip('/'))]
+        names = set()
+        for name in filenames:
+            names.add(name.split('/')[0])
+        names = list(names)
+        impl = impl_hg_tree if opts.full_tree else impl_hg_node
+    elif opts.type == 'svn':
+        repo = pysvn.Client()
+        if opts.cid == 'HEAD':
+            cid = pysvn.Revision(pysvn.opt_revision_kind.head)
+        else:
+            cid = pysvn.Revision(pysvn.opt_revision_kind.number, opts.cid)
+        path = opts.path.strip('/')
+        names = []
+        impl = impl_svn_tree if opts.full_tree else impl_svn_node
+
+    sys.stdout.write('Timing %s' % ('full tree' if opts.full_tree else 'node'))
+    sys.stdout.flush()
+    total = 0.0
+    for i in range(opts.count):
+        sys.stdout.write('.')
+        sys.stdout.flush()
+        start = datetime.now()
+        impl(repo, cid, path, names, opts.repo_path)
+        end = datetime.now()
+        total += (end - start).total_seconds()
+    print
+    print 'Total time:           %s' % total
+    print 'Average time per run: %s' % (total / opts.count)
+
+
+def impl_git_tree(repo, cid, path, names, *args):
+    data = {}
+    for name in names:
+        #data[name] = repo.git.rev_list(cid, '--', os.path.join(path, name), max_count=1)
+        data[name] = git.Commit.iter_items(repo, cid, os.path.join(path, name), max_count=1).next().hexsha
+    return data
+
+def impl_git_node(repo, cid, path, *args):
+    #return repo.git.rev_list(cid, '--', path, max_count=1)
+    return git.Commit.iter_items(repo, cid, path, max_count=1).next().hexsha
+
+
+def impl_hg_tree(repo, cid, path, names, *args):
+    m = cmdutil.match(repo, pats=[path], default=path)
+    data = {}
+    for name in names:
+        rev_iter = cmdutil.walkchangerevs(repo, m, {'rev': cid}, lambda c,f: None)
+        data[name] = rev_iter.next().hex()
+    return data
+
+def impl_hg_node(repo, cid, path, *args):
+    m = cmdutil.match(repo, pats=[path], default=path)
+    rev_iter = cmdutil.walkchangerevs(repo, m, {'rev': cid}, lambda c,f: None)
+    return rev_iter.next().hex()
+
+def impl_svn_tree(repo, cid, path, names, repo_path, *args):
+    infos = repo.info2(
+            'file://%s/%s' % (repo_path, path),
+            revision=cid,
+            depth=pysvn.depth.immediates)
+    data = {}
+    for name, info in infos[1:]:
+        data[name] = info.last_changed_rev
+    return data
+
+def impl_svn_node(repo, cid, path, names, repo_path, *args):
+    logs = repo.log(
+            'file://%s/%s' % (repo_path, path),
+            revision_start=cid,
+            limit=1)
+    return logs[0].revision.number
+
+
+class HgUI(ui.ui):
+    '''Hg UI subclass that suppresses reporting of untrusted hgrc files.'''
+    def __init__(self, *args, **kwargs):
+        super(HgUI, self).__init__(*args, **kwargs)
+        self._reportuntrusted = False
+
+def parse_opts():
+    parser = argparse.ArgumentParser(description='Benchmark getting LCD from repo tool')
+    parser.add_argument('--type', default='git', dest='type',
+            help='Type of repository being tested.')
+    parser.add_argument('--repo-path', dest='repo_path', required=True,
+            help='Path to the repository to test against')
+    parser.add_argument('--commit', default='HEAD', dest='cid',
+            help='Commit ID or revision number to test against')
+    parser.add_argument('--path', default='', dest='path',
+            help='Path within the repository to test against')
+    parser.add_argument('--count', type=int, default=100, dest='count',
+            help='Number of times to execute')
+    parser.add_argument('--full-tree', action='store_true', default=False, dest='full_tree',
+            help='Time full tree listing instead of just the single node')
+    return parser.parse_args()
+
+if __name__ == '__main__':
+    main(parse_opts())

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/548b7328/scripts/perf/md_perf.py
----------------------------------------------------------------------
diff --git a/scripts/perf/md_perf.py b/scripts/perf/md_perf.py
new file mode 100644
index 0000000..708a296
--- /dev/null
+++ b/scripts/perf/md_perf.py
@@ -0,0 +1,130 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+"""
+A script for timing/profiling the Markdown conversion of an artifact discussion thread.
+
+Example usage:
+
+(env-allura)root@h1v1024:/var/local/allura/Allura(master)$ time paster script production.ini
allura/scripts/md_perf.py -- --converter=forge
+      Conversion Time (s)  Text Size Post._id
+   1 0.021863937377929688         20 7d3ce86bb2c3afaee21f28547ed542d0c8c483b8
+   2 0.002238035202026367         12 96b1283c6db619cd66ee092551758dc1ad5b958f
+   3 0.001832962036132812          9 42c44cd72815d29069378353745bef953bdb2b98
+   4 0.011796951293945312        901 cadbea52291c58bb190597c1df94527369b405fa
+   5 0.143218040466308594      11018 362bee7ef1ba4e062712bda22cb96ae9fe459b95
+   6 0.029596090316772461       1481 46b78785b849f55d24cf32ee1f4e4c916cb7a6fe
+   7 0.045151948928833008       4144 4e2f62188080baba9b88c045ba1f7c26903bfcf9
+   8 0.637056827545166016      14553 51c87f2b1d55c08147bb2353e20361236232b432
+   9 4.510329008102416992      23016 f298ad88584f3dc9b5c37ffde61391bf03d5bae6
+  10 3.614714860916137695      23016 8775a230b19c231daa1608bb4cea1e17aab54550
+  11 0.393079042434692383      19386 ed79e0d2f89366043a007e0837e98945453508c9
+  12 0.000739097595214844      43659 56ac2437ec1bd886a03d23e45aa1c947729760ec
+  13 0.258469104766845703       8520 57152cefe0424b7fc9dff7ab4d21a6ef6e90bf82
+  14 0.264052867889404297       8518 6788b13c90c9719ba46196a0a773f4c228df9f2a
+  15 0.995774984359741211      14553 3f5cce06d2400bcd56d7b90d12c569935f0099a4
+Total time: 10.930670023
+
+real    0m14.256s
+user    0m12.749s
+sys     0m1.112s
+
+"""
+
+import argparse
+import cProfile
+import re
+import sys
+import time
+
+from mock import patch
+
+try:
+    import re2
+    re2.set_fallback_notification(re2.FALLBACK_WARNING)
+    RE2_INSTALLED = True
+except ImportError:
+    RE2_INSTALLED = False
+
+from pylons import app_globals as g
+
+MAX_OUTPUT = 99999
+DUMMYTEXT = None
+
+
+def get_artifact():
+    from forgeblog import model as BM
+    return BM.BlogPost.query.get(
+            slug='2013/09/watch-breaking-bad-season-5-episode-16-felina-live-streaming')
+
+
+def main(opts):
+    import markdown
+    if opts.re2 and RE2_INSTALLED:
+        markdown.inlinepatterns.re = re2
+    converters = {
+        'markdown': lambda: markdown.Markdown(),
+        'markdown_safe': lambda: markdown.Markdown(safe_mode=True),
+        'markdown_escape': lambda: markdown.Markdown(safe_mode='escape'),
+        'forge': lambda: g.markdown,
+        }
+    md = converters[opts.converter]()
+    artifact = get_artifact()
+    return render(artifact, md, opts)
+
+
+def render(artifact, md, opts):
+    start = begin = time.time()
+    print "%4s %20s %10s %s" % ('', 'Conversion Time (s)', 'Text Size', 'Post._id')
+    for i, p in enumerate(artifact.discussion_thread.posts):
+        text = DUMMYTEXT or p.text
+        if opts.n and i + 1 not in opts.n:
+            print 'Skipping post %s' % str(i + 1)
+            continue
+        if opts.profile:
+            print 'Profiling post %s' % str(i + 1)
+            cProfile.runctx('output = md.convert(text)', globals(), locals())
+        else:
+            output = md.convert(text)
+        elapsed = time.time() - start
+        print "%4s %1.18f %10s %s" % (i + 1, elapsed, len(text), p._id)
+        if opts.output:
+            print 'Input:', text[:min(300, len(text))]
+            print 'Output:', output[:min(MAX_OUTPUT, len(output))]
+        start = time.time()
+    print "Total time:", start - begin
+    return output
+
+
+def parse_options():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--converter', default='markdown')
+    parser.add_argument('--profile', action='store_true', help='Run profiler and output timings')
+    parser.add_argument('--output', action='store_true', help='Print result of markdown conversion')
+    parser.add_argument('--re2', action='store_true', help='Run with re2 instead of re')
+    parser.add_argument('--compare', action='store_true', help='Run with re and re2, and
compare results')
+    parser.add_argument('-n', '--n', nargs='+', type=int, help='Only convert nth post(s)
in thread')
+    return parser.parse_args()
+
+
+if __name__ == '__main__':
+    opts = parse_options()
+    out1 = main(opts)
+    if opts.compare:
+        opts.re2 = not opts.re2
+        out2 = main(opts)
+        print 're/re2 outputs match: ', out1 == out2

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/548b7328/scripts/perf/sstress.py
----------------------------------------------------------------------
diff --git a/scripts/perf/sstress.py b/scripts/perf/sstress.py
new file mode 100644
index 0000000..5e53a52
--- /dev/null
+++ b/scripts/perf/sstress.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+'''
+sstress - an SMTP stress testing tool
+'''
+
+import smtplib
+import threading
+import time
+
+C = 5
+N = 1000
+TOADDR = 'nobody@localhost'
+SERVER = 'localhost'
+PORT = 8825
+SIZE = 10 * (2**10)
+EMAIL_TEXT = 'X' * SIZE
+
+def main():
+    threads = [ threading.Thread(target=stress) for x in xrange(C) ]
+    begin = time.time()
+    for t in threads:
+        t.start()
+    for t in threads:
+        t.join()
+    end = time.time()
+    elapsed = end - begin
+    print '%d requests completed in %f seconds' % (N, elapsed)
+    print '%f requests/second' % (N/elapsed)
+
+def stress():
+    server = smtplib.SMTP(SERVER, PORT)
+    for x in xrange(N/C):
+        server.sendmail('sstress@localhost', TOADDR, EMAIL_TEXT)
+
+if __name__ == '__main__':
+    main()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/548b7328/scripts/sstress.py
----------------------------------------------------------------------
diff --git a/scripts/sstress.py b/scripts/sstress.py
deleted file mode 100644
index 5e53a52..0000000
--- a/scripts/sstress.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env python
-
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-'''
-sstress - an SMTP stress testing tool
-'''
-
-import smtplib
-import threading
-import time
-
-C = 5
-N = 1000
-TOADDR = 'nobody@localhost'
-SERVER = 'localhost'
-PORT = 8825
-SIZE = 10 * (2**10)
-EMAIL_TEXT = 'X' * SIZE
-
-def main():
-    threads = [ threading.Thread(target=stress) for x in xrange(C) ]
-    begin = time.time()
-    for t in threads:
-        t.start()
-    for t in threads:
-        t.join()
-    end = time.time()
-    elapsed = end - begin
-    print '%d requests completed in %f seconds' % (N, elapsed)
-    print '%f requests/second' % (N/elapsed)
-
-def stress():
-    server = smtplib.SMTP(SERVER, PORT)
-    for x in xrange(N/C):
-        server.sendmail('sstress@localhost', TOADDR, EMAIL_TEXT)
-
-if __name__ == '__main__':
-    main()


Mime
View raw message