[PATCH] performance history specification

John Arbash Meinel john at arbash-meinel.com
Wed Jul 12 20:29:27 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jan Balster wrote:
> Hi all,
> 
> at europython Robert Collins, Carl Friedrich Bolz and Holger Krekel started a
> branch to implement the performance history specification
> (https://launchpad.net/products/bzr/+spec/performance-history).
> The branch is located at codespeak.net:
> http://codespeak.net/bzr/branches/bzr.performance-history
> 
> Robert suggested to merge the changes into the main branch, so here is the
> official request, the bundle is attached.
> 
> Cheers,
>        Jan
> 

...

> -    def __init__(self, stream, descriptions, verbosity, pb=None):
> +    def __init__(self, stream, descriptions, verbosity, pb=None,
> +                 bench_history=None):
>          unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
>          self.pb = pb
> +        if bench_history is not None:
> +            bench_history.write("--date %s\n" % time.time())
> +        self._bench_history = bench_history

Seems like you are writing a timestamp from epoch time here, rather than
a date. It would look nice if you wrote:

bench_history.write(time.strftime('--date %Y-%m-%d %H:%M:%S\n'))

Or if you want something more official, maybe:
bench_history.write('--date %s\n' %
		    (datetime.datetime.utcnow().isoformat(),))

But in general, if it is for human viewing time.time() is not very good.

...


v-- minor grammer fix
        vv
we want to profile a call

> +        # we want profile a call and check that its test duration is recorded
> +        # make a new test instance that when run will generate a benchmark
> +        example_test_case = TestTestResult("_time_hello_world_encoding")
> +        # execute the test, which should succeed and record times
> +        example_test_case.run(result)
> +        lines = result_stream.getvalue().splitlines()
> +        self.assertEqual(2, len(lines))
> +        self.assertContainsRe(lines[1],
> +            " *[0-9]+ms bzrlib.tests.test_selftest.TestTestResult"
> +            "._time_hello_world_encoding")
> + 

It looks pretty good. The only thing it isn't doing is checking to make
sure .perf-history isn't being overwritten.
Also, it wasn't clear where it was creating the .perf-history file. I
assume you were shooting for putting it inside the project (not the test
temp dirs)
Which means that .bzrignore should be updated to ignore the newly
generated file.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEtU2XJdeBCYSNAAMRAj10AJ9GTbbkOqitf9tAfmiHc6cuyOckZQCggHiE
K5QsEl+Z7NdYn4fgn0eoj/I=
=r6D0
-----END PGP SIGNATURE-----




More information about the bazaar mailing list