This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author adamtj
Recipients adamtj
Date 2012-03-30.16:45:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333125926.46.0.263686437427.issue14453@psf.upfronthosting.co.za>
In-reply-to
Content
profile.Profile.calibrate can only produces a bias for the default timer.  If you've specified a different timer, it will not be used when calibrating.

Additionally, setting profile.Profile.bias will affect the computed bias.  It will produce a bias that must be added to profile.Profile.bias and cannot be used independently, which is surprising.

The fix is to change
    p = Profile()
to 
    p = Profile(timer=self.timer, bias=0)
in _calibrate_inner().

The attached patch makes that change and additionally removes some code that temporarily resets self.bias in calibrate(), as it had no effect.  Perhaps Profile.bias was meant instead.  At any rate, _calibrate_inner() no longer needs to exist, but is left for backwards compatibility.

This will demonstrate the problem with calibrating after setting profile.Profile.bias:

import profile
profile.Profile.bias = profile.Profile().calibrate(100000); 
print '%+.9f' % profile.Profile.bias
profile.Profile.bias = profile.Profile().calibrate(100000); 
print '%+.9f' % profile.Profile.bias
History
Date User Action Args
2012-03-30 16:45:26adamtjsetrecipients: + adamtj
2012-03-30 16:45:26adamtjsetmessageid: <1333125926.46.0.263686437427.issue14453@psf.upfronthosting.co.za>
2012-03-30 16:45:25adamtjlinkissue14453 messages
2012-03-30 16:45:25adamtjcreate