-
Notifications
You must be signed in to change notification settings - Fork 1.1k
replace format with %s in logging calls #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rebased. I'll wait a day before merging. |
Did you get an estimate on how much of an improvement this is in On Tue, Oct 27, 2015 at 10:33 AM, Will Holmgren [email protected]
|
Good question. I only tested With the current %%timeit
tracker_data = pvlib.tracking.singleaxis(pyephemout['apparent_zenith'], pyephemout['apparent_azimuth'],
axis_tilt=0, axis_azimuth=180, max_angle=90,
backtrack=True, gcr=2.0/7.0)
10 loops, best of 3: 138 ms per loop And if I run %lprun -f pvlib.tracking.singleaxis pvlib.tracking.singleaxis(pyephemout['apparent_zenith'], pyephemout['apparent_azimuth'], axis_tilt=0, axis_azimuth=180, max_angle=90, backtrack=True, gcr=2.0/7.0) I see that ~75% of the time is spent on the After a from importlib import reload
pvlib = reload(pvlib)
pvlib.tracking = reload(pvlib.tracking) ...with the current PR %%timeit
tracker_data = pvlib.tracking.singleaxis(pyephemout['apparent_zenith'], pyephemout['apparent_azimuth'],
axis_tilt=0, axis_azimuth=180, max_angle=90,
backtrack=True, gcr=2.0/7.0)
10 loops, best of 3: 26 ms per loop More than 5x faster! Face, meet palm. And if I run %lprun -f pvlib.tracking.singleaxis pvlib.tracking.singleaxis(pyephemout['apparent_zenith'], pyephemout['apparent_azimuth'], axis_tilt=0, axis_azimuth=180, max_angle=90, backtrack=True, gcr=2.0/7.0) those logging calls take 0.0% of the time. Note that the logging call on line 100 still uses 1% of the time due to the fact that Python must still call Finally some numbers to back up the claim that single value formatting is already reasonably fast and to justify the fact that I don't want to bother to benchmark the rest of the library: # numpy float
In [21]:
a = np.float64(1)
b = np.float64(2)
In [22]:
%%timeit
'{} {}'.format(a, b)
The slowest run took 15.96 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 1.91 µs per loop
# python int
In [23]:
a = 1
b = 2
In [24]:
%%timeit
'{} {}'.format(a, b)
The slowest run took 8.39 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 535 ns per loop
# python float
In [27]:
a = 1.
b = 2.
In [29]:
%%timeit
'{} {}'.format(a, b)
The slowest run took 10.21 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 916 ns per loop So it's faster to format native python ints than native python floats than numpy floats. All of these times are much faster than any of the functions that they'd be found in. |
Great, thanks. On Tue, Oct 27, 2015 at 6:58 PM, Will Holmgren [email protected]
|
I added a 0.2.2 whatsnew doc with a note about this change. It can be renamed in the future if we go straight to 0.3. |
replace format with %s in logging calls
closes #89
I'll rebase this on #90 once I work out yet another CI issue in that.