4

1

I have no idea if the performance I'm seeing out of FogBugz is reasonable or not. How do I tell?

flag

1 Answer

3

Here's a Python script which uses the API to edit a wiki page of your choosing (on your FogBugz or FogBugz On Demand site) two hundred times. It fully replaces the contents of the wiki page.

On each iteration, the script grabs the contents of the wiki page, parses the timestamps already on the page, determines the length of time between those timestamps, and runs some basic stats on the durations. Those stats go into a table at the top of the page, and a new timestamp is added to the bottom of the page.

Rinse. Repeat.

The script requires Python 2.7. It also relies on your putting an API token into a file in the same directory called token.txt.

#!/usr/local/bin/python
import re, string, sys, pprint, time
from math import sqrt
from datetime import tzinfo, timedelta, datetime
from fogbugz import FogBugz
from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup, CData
import urllib
import urllib2


def meanstdv(x):
    x = sorted(x)
    n, mean, std = len(x), 0, 0
    mean = sum(x)/len(x)
    median = x[int(len(x)/2)]
    quart = x[int(len(x)*0.75)]

    max1 = max(x)
    min1 = min(x)

    for a in x:
        std = std + (a - mean)**2
        std = sqrt(std / float(n-1))
    return mean, std, min1, max1, median, quart


token_file = open("./token.txt")
try:
    token_list = [k.strip() for k in token_file.readlines()]
finally:
    token_file.close()
token = token_list[0]

wiki_page_index = 1234
fogbugz = FogBugz('https://your.fogbugz.com',token)

res = fogbugz.editArticle(ixWikiPage=wiki_page_index,sHeadline="Performance Test",sBody="<table></table>")

for j in range(200):
    before_view = datetime.today()
    res1 = fogbugz.viewArticle(ixWikiPage=wiki_page_index)
    for n in res1.findAll('sbody'):
        current_body = n.text
        next_body = "%s\n<p>%s</p>" % (current_body, before_view.strftime('%Y-%m-%d %H:%M:%S.%f'))
    get_p = BeautifulSoup(next_body)
    timestamps = [x.text for x in get_p.findAll('p')]
    diffs  = [datetime.strptime(stamps,'%Y-%m-%d %H:%M:%S.%f') for stamps in timestamps]
    this_table = "<table></table>"
    if len(diffs) > 3:
        #take the list minus its last member and zip it with the list minus its first member
        # then compare those tuples to each other
        diffs3 = [(x[1] - x[0]).total_seconds() for x in zip(diffs[:-1],diffs[1:])]
        this_table = """<table>
        <tr><td>Mean</td><td>%f</td></tr>
        <tr><td>Std Dev</td><td>%f</td></tr>
        <tr><td>Min</td><td>%f</td></tr>
        <tr><td>Max</td><td>%f</td></tr>
        <tr><td>Median</td><td>%f</td></tr>
        <tr><td>Quartile</td><td>%f</td></tr>
        </table>""" % meanstdv(diffs3)
    next_body = "%s %s %s" % (this_table, "\n".join([ "<p>%s</p>" % y for y in timestamps]), before_view.strftime('%Y-%m-%d %H:%M:%S.%f'))
    res = fogbugz.editArticle(ixWikiPage=wiki_page_index,sHeadline="Performance Test",sBody=next_body)
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.