[Numpy-discussion] vectorizing loops

Francesc Altet faltet@carabos....
Wed Oct 31 05:18:14 CDT 2007


A Wednesday 31 October 2007, Mathew Yeates escrigué:
[...]
> I also took a look at NumExpr. While it wasn't something I needed for
> vectorizing, it still looks very interesting. What kinds of
> performance improvements would be expected using this?

Well, for some speedup figures you can always check the first (and very 
exciting) message (and many of the interesting followups) of the 
original author, David Cooke, in this very same list:

http://thread.gmane.org/gmane.comp.python.numeric.general/4081/focus=4138

This was back in March 2006.  Since then, David Cooke and Tim Hochberg 
(with some additions of Ivan Vilata and myself) have added many 
interesting functionality, like the support for logical and comparison 
operators, many functions, like 'where', 'sqrt' and all the 
trigonometric and inverse trigonometric, reductions ('sum' and 'prod') 
and also optimizations for some specific operations, like division 
(a/b) or exponentation (a**b) with floating points, among others.

I'm attaching a file (timing2-orig.out) with the results of the 
file 'timing.py' that comes with the numexpr distribution for more 
up-to-date figures (all the runs mentioned here have been executed on a 
Opteron at 2 GHz machine).  On it, you can see that the speed-ups for a 
variety of tests range from 1.1x up to 8.7x, being the mean speedup of 
aproximately 2x, which is pretty good.

Furthermore, and due to the specifics needs of Pytables (mainly, for 
doing 'in-core' selections in tables), Ivan and me have ended creating 
an enhanced version of numexpr that has improved support for more 
datatypes (long integers and strings, mainly), improvements for boolean 
operations and specific optimization for unidimensional arrays being 
strided and/or unaligned (these cases can be quite common in PyTables).  

You can see the result of these improvements in the 
attached 'boolean_timing-tables.out' file which is the output of the 
(also attached) benchmark 'boolean_timing.py' 
(see 'boolean_timing-orig.out' for the results using the original 
numexpr).  The main things to notice is that, for these kind 
of 'boolean' computations, the Pytables version of numexpr can be more 
than 3x faster than plain Numpy and up to 1.8x faster (2.0x for the 
unidimensional strided case) than the original numexpr.

Incidentally, all the improvements of the PyTables flavor of numexpr 
have been reported to the original authors, but, for the sake of 
keeping numexpr simple, they decided to implement only some of them.  
However, people is encouraged to try out the Pytables flavor from:

http://www.pytables.org/trac/browser/trunk/tables/numexpr/

Or, by installing PyTables 2.x series and importing numexpr as: 

"from tables import numexpr"

Cheers,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"
-------------- next part --------------
Expression: b*c+d*e
numpy: 0.0432945489883
Skipping weave timing
numexpr: 0.024453997612
Speed-up of numexpr over numpy: 1.77044872889

Expression: 2*a+3*b
numpy: 0.0386545658112
Skipping weave timing
numexpr: 0.019765496254
Speed-up of numexpr over numpy: 1.95565875577

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.271282076836
Skipping weave timing
numexpr: 0.244947910309
Speed-up of numexpr over numpy: 1.10750925163

Expression: 2*a + arctan2(a, b)
numpy: 0.136862039566
Skipping weave timing
numexpr: 0.120795488358
Speed-up of numexpr over numpy: 1.13300621925

Expression: a**2 + (b+1)**-2.5
numpy: 0.328014492989
Skipping weave timing
numexpr: 0.0521146059036
Speed-up of numexpr over numpy: 6.29409907839

Expression: (a+1)**50
numpy: 0.278326034546
Skipping weave timing
numexpr: 0.0682574510574
Speed-up of numexpr over numpy: 4.07759197324

Expression: sqrt(a**2 + b**2)
numpy: 0.0681229829788
Skipping weave timing
numexpr: 0.0376839637756
Speed-up of numexpr over numpy: 1.80774462539

Average = 1.64964169387
Expression: b*c+d*e
numpy: 0.0410040616989
Skipping weave timing
numexpr: 0.022455573082
Speed-up of numexpr over numpy: 1.82600824968

Expression: 2*a+3*b
numpy: 0.0371245145798
Skipping weave timing
numexpr: 0.0187830924988
Speed-up of numexpr over numpy: 1.97648574547

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.270690441132
Skipping weave timing
numexpr: 0.246992945671
Speed-up of numexpr over numpy: 1.09594401733

Expression: 2*a + arctan2(a, b)
numpy: 0.137767076492
Skipping weave timing
numexpr: 0.120716929436
Speed-up of numexpr over numpy: 1.14124072851

Expression: a**2 + (b+1)**-2.5
numpy: 0.331321954727
Skipping weave timing
numexpr: 0.0489059686661
Speed-up of numexpr over numpy: 6.77467318947

Expression: (a+1)**50
numpy: 0.27830851078
Skipping weave timing
numexpr: 0.0324734449387
Speed-up of numexpr over numpy: 8.57034143763

Expression: sqrt(a**2 + b**2)
numpy: 0.0671869516373
Skipping weave timing
numexpr: 0.0361994504929
Speed-up of numexpr over numpy: 1.8560213131

Average = 2.11279224374
Expression: b*c+d*e
numpy: 0.0418599843979
Skipping weave timing
numexpr: 0.0225175619125
Speed-up of numexpr over numpy: 1.85899275243

Expression: 2*a+3*b
numpy: 0.0368804931641
Skipping weave timing
numexpr: 0.0186915397644
Speed-up of numexpr over numpy: 1.97311155897

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.270949482918
Skipping weave timing
numexpr: 0.242916107178
Speed-up of numexpr over numpy: 1.11540352785

Expression: 2*a + arctan2(a, b)
numpy: 0.137181043625
Skipping weave timing
numexpr: 0.119929432869
Speed-up of numexpr over numpy: 1.14384801415

Expression: a**2 + (b+1)**-2.5
numpy: 0.328627943993
Skipping weave timing
numexpr: 0.0484969615936
Speed-up of numexpr over numpy: 6.77625841277

Expression: (a+1)**50
numpy: 0.278501987457
Skipping weave timing
numexpr: 0.0319650173187
Speed-up of numexpr over numpy: 8.7127119213

Expression: sqrt(a**2 + b**2)
numpy: 0.0678375959396
Skipping weave timing
numexpr: 0.0358920097351
Speed-up of numexpr over numpy: 1.89004729577

Average = 2.13367031666
Expression: b*c+d*e
numpy: 0.0413310527802
Skipping weave timing
numexpr: 0.0224200487137
Speed-up of numexpr over numpy: 1.84348630585

Expression: 2*a+3*b
numpy: 0.0371279716492
Skipping weave timing
numexpr: 0.0207829475403
Speed-up of numexpr over numpy: 1.78646323276

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.270565509796
Skipping weave timing
numexpr: 0.245254993439
Speed-up of numexpr over numpy: 1.1032008197

Expression: 2*a + arctan2(a, b)
numpy: 0.137845516205
Skipping weave timing
numexpr: 0.120264410973
Speed-up of numexpr over numpy: 1.146187098

Expression: a**2 + (b+1)**-2.5
numpy: 0.327829003334
Skipping weave timing
numexpr: 0.0490430593491
Speed-up of numexpr over numpy: 6.68451372498

Expression: (a+1)**50
numpy: 0.27824151516
Skipping weave timing
numexpr: 0.0320014953613
Speed-up of numexpr over numpy: 8.6946410478

Expression: sqrt(a**2 + b**2)
numpy: 0.0679360628128
Skipping weave timing
numexpr: 0.0359455347061
Speed-up of numexpr over numpy: 1.88997224184

Average = 2.10440586099
Expression: b*c+d*e
numpy: 0.0416020154953
Skipping weave timing
numexpr: 0.0223726034164
Speed-up of numexpr over numpy: 1.85950712668

Expression: 2*a+3*b
numpy: 0.0368609428406
Skipping weave timing
numexpr: 0.0182800292969
Speed-up of numexpr over numpy: 2.01645972454

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.271070599556
Skipping weave timing
numexpr: 0.246081471443
Speed-up of numexpr over numpy: 1.10154819039

Expression: 2*a + arctan2(a, b)
numpy: 0.136904478073
Skipping weave timing
numexpr: 0.119737029076
Speed-up of numexpr over numpy: 1.14337627324

Expression: a**2 + (b+1)**-2.5
numpy: 0.328311920166
Skipping weave timing
numexpr: 0.0483285188675
Speed-up of numexpr over numpy: 6.79333709908

Expression: (a+1)**50
numpy: 0.278018951416
Skipping weave timing
numexpr: 0.0320415496826
Speed-up of numexpr over numpy: 8.67682600155

Expression: sqrt(a**2 + b**2)
numpy: 0.0675255060196
Skipping weave timing
numexpr: 0.0356780290604
Speed-up of numexpr over numpy: 1.89263554624

Average = 2.13488090561
Expression: b*c+d*e
numpy: 0.0417284965515
Skipping weave timing
numexpr: 0.0224235057831
Speed-up of numexpr over numpy: 1.86092651859

Expression: 2*a+3*b
numpy: 0.0372844934464
Skipping weave timing
numexpr: 0.0183354616165
Speed-up of numexpr over numpy: 2.03346358145

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.271299004555
Skipping weave timing
numexpr: 0.242529511452
Speed-up of numexpr over numpy: 1.11862264898

Expression: 2*a + arctan2(a, b)
numpy: 0.137305498123
Skipping weave timing
numexpr: 0.11990404129
Speed-up of numexpr over numpy: 1.14512819289

Expression: a**2 + (b+1)**-2.5
numpy: 0.328257918358
Skipping weave timing
numexpr: 0.0484659671783
Speed-up of numexpr over numpy: 6.77295713815

Expression: (a+1)**50
numpy: 0.278239488602
Skipping weave timing
numexpr: 0.0320734977722
Speed-up of numexpr over numpy: 8.67505909638

Expression: sqrt(a**2 + b**2)
numpy: 0.0679830312729
Skipping weave timing
numexpr: 0.0358599424362
Speed-up of numexpr over numpy: 1.89579309542

Average = 2.13654093381
Expression: b*c+d*e
numpy: 0.0416275262833
Skipping weave timing
numexpr: 0.0223845243454
Speed-up of numexpr over numpy: 1.85965650379

Expression: 2*a+3*b
numpy: 0.0367059707642
Skipping weave timing
numexpr: 0.0184335708618
Speed-up of numexpr over numpy: 1.99125666098

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.27404999733
Skipping weave timing
numexpr: 0.245867967606
Speed-up of numexpr over numpy: 1.11462261635

Expression: 2*a + arctan2(a, b)
numpy: 0.137671470642
Skipping weave timing
numexpr: 0.120179057121
Speed-up of numexpr over numpy: 1.14555292694

Expression: a**2 + (b+1)**-2.5
numpy: 0.328163504601
Skipping weave timing
numexpr: 0.0487785339355
Speed-up of numexpr over numpy: 6.72762131462

Expression: (a+1)**50
numpy: 0.278432488441
Skipping weave timing
numexpr: 0.0322035551071
Speed-up of numexpr over numpy: 8.64601710946

Expression: sqrt(a**2 + b**2)
numpy: 0.0673484802246
Skipping weave timing
numexpr: 0.0359764099121
Speed-up of numexpr over numpy: 1.87201781359

Average = 2.12334044961
Expression: b*c+d*e
numpy: 0.0412619113922
Skipping weave timing
numexpr: 0.0225330591202
Speed-up of numexpr over numpy: 1.8311721978

Expression: 2*a+3*b
numpy: 0.0367000102997
Skipping weave timing
numexpr: 0.0186544656754
Speed-up of numexpr over numpy: 1.96735789373

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.269914507866
Skipping weave timing
numexpr: 0.242934584618
Speed-up of numexpr over numpy: 1.11105838755

Expression: 2*a + arctan2(a, b)
numpy: 0.137315988541
Skipping weave timing
numexpr: 0.119785428047
Speed-up of numexpr over numpy: 1.14634969194

Expression: a**2 + (b+1)**-2.5
numpy: 0.328106999397
Skipping weave timing
numexpr: 0.0484600067139
Speed-up of numexpr over numpy: 6.77067589641

Expression: (a+1)**50
numpy: 0.27797794342
Skipping weave timing
numexpr: 0.0319224596024
Speed-up of numexpr over numpy: 8.70791119742

Expression: sqrt(a**2 + b**2)
numpy: 0.0679694414139
Skipping weave timing
numexpr: 0.0358340740204
Speed-up of numexpr over numpy: 1.89678241372

Average = 2.13011887987
Expression: b*c+d*e
numpy: 0.0415569543839
Skipping weave timing
numexpr: 0.0224959850311
Speed-up of numexpr over numpy: 1.84730538922

Expression: 2*a+3*b
numpy: 0.0367209911346
Skipping weave timing
numexpr: 0.0182545185089
Speed-up of numexpr over numpy: 2.01161104944

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.270547986031
Skipping weave timing
numexpr: 0.243052005768
Speed-up of numexpr over numpy: 1.11312797101

Expression: 2*a + arctan2(a, b)
numpy: 0.137174010277
Skipping weave timing
numexpr: 0.119675517082
Speed-up of numexpr over numpy: 1.14621614864

Expression: a**2 + (b+1)**-2.5
numpy: 0.327585458755
Skipping weave timing
numexpr: 0.0484219789505
Speed-up of numexpr over numpy: 6.76522244352

Expression: (a+1)**50
numpy: 0.278404474258
Skipping weave timing
numexpr: 0.0317900180817
Speed-up of numexpr over numpy: 8.75760666582

Expression: sqrt(a**2 + b**2)
numpy: 0.0682315826416
Skipping weave timing
numexpr: 0.0355939865112
Speed-up of numexpr over numpy: 1.91694129625

Average = 2.14163917854
Expression: b*c+d*e
numpy: 0.0415704250336
Skipping weave timing
numexpr: 0.0228176116943
Speed-up of numexpr over numpy: 1.82185697567

Expression: 2*a+3*b
numpy: 0.0368599891663
Skipping weave timing
numexpr: 0.0182430744171
Speed-up of numexpr over numpy: 2.02049217821

Expression: 2*a + (cos(3)+5)*sinh(cos(b))
numpy: 0.269914984703
Skipping weave timing
numexpr: 0.246359467506
Speed-up of numexpr over numpy: 1.09561441837

Expression: 2*a + arctan2(a, b)
numpy: 0.137582421303
Skipping weave timing
numexpr: 0.120151996613
Speed-up of numexpr over numpy: 1.14506978812

Expression: a**2 + (b+1)**-2.5
numpy: 0.328064441681
Skipping weave timing
numexpr: 0.0486860275269
Speed-up of numexpr over numpy: 6.73836947366

Expression: (a+1)**50
numpy: 0.278306007385
Skipping weave timing
numexpr: 0.032343506813
Speed-up of numexpr over numpy: 8.60469487721

Expression: sqrt(a**2 + b**2)
numpy: 0.0673480033875
Skipping weave timing
numexpr: 0.0361359119415
Speed-up of numexpr over numpy: 1.863741629

Average = 2.11725812184
Averages: 18.15, 23.24, 23.47, 23.15, 23.48, 23.50, 23.36, 23.43, 23.56, 23.29
-------------- next part --------------
Python version:    2.5 (r25:51908, Nov  3 2006, 12:01:01) 
[GCC 4.0.2 20050901 (prerelease) (SUSE Linux)]
NumPy version:     1.0.3
******************* Expression: i2 > 0
numpy: 0.00318
numpy strided: 0.00695
numpy unaligned: 0.01249
numexpr: 0.02332 Speed-up of numexpr over numpy: 0.1364
numexpr strided: 0.02728 Speed-up of numexpr strided over numpy: 0.2548
numexpr unaligned: 0.02604 Speed-up of numexpr unaligned over numpy: 0.4796
******************* Expression: i2 < 0
numpy: 0.00309
numpy strided: 0.00698
numpy unaligned: 0.01153
numexpr: 0.02358 Speed-up of numexpr over numpy: 0.131
numexpr strided: 0.02708 Speed-up of numexpr strided over numpy: 0.2578
numexpr unaligned: 0.02599 Speed-up of numexpr unaligned over numpy: 0.4436
******************* Expression: i2 < f3
numpy: 0.00872
numpy strided: 0.01488
numpy unaligned: 0.02254
numexpr: 0.02757 Speed-up of numexpr over numpy: 0.3163
numexpr strided: 0.03473 Speed-up of numexpr strided over numpy: 0.4284
numexpr unaligned: 0.04398 Speed-up of numexpr unaligned over numpy: 0.5125
******************* Expression: i2-10 < f3
numpy: 0.01517
numpy strided: 0.02121
numpy unaligned: 0.0332
numexpr: 0.02946 Speed-up of numexpr over numpy: 0.5149
numexpr strided: 0.0375 Speed-up of numexpr strided over numpy: 0.5656
numexpr unaligned: 0.04521 Speed-up of numexpr unaligned over numpy: 0.7344
******************* Expression: i2*f3+f3*f3 > i2
numpy: 0.05012
numpy strided: 0.06811
numpy unaligned: 0.09033
numexpr: 0.0344 Speed-up of numexpr over numpy: 1.457
numexpr strided: 0.04196 Speed-up of numexpr strided over numpy: 1.6232
numexpr unaligned: 0.04948 Speed-up of numexpr unaligned over numpy: 1.8256
******************* Expression: 0.1*i2 > arctan2(i2, f3)
numpy: 0.13276
numpy strided: 0.14845
numpy unaligned: 0.15729
numexpr: 0.12835 Speed-up of numexpr over numpy: 1.0344
numexpr strided: 0.1368 Speed-up of numexpr strided over numpy: 1.0852
numexpr unaligned: 0.14563 Speed-up of numexpr unaligned over numpy: 1.0801
******************* Expression: i2%2 > 3
numpy: 0.03263
numpy strided: 0.03386
numpy unaligned: 0.04204
numexpr: 0.06113 Speed-up of numexpr over numpy: 0.5338
numexpr strided: 0.06615 Speed-up of numexpr strided over numpy: 0.5119
numexpr unaligned: 0.06473 Speed-up of numexpr unaligned over numpy: 0.6495
******************* Expression: i2%10 < 4
numpy: 0.0327
numpy strided: 0.03373
numpy unaligned: 0.04215
numexpr: 0.06154 Speed-up of numexpr over numpy: 0.5314
numexpr strided: 0.06539 Speed-up of numexpr strided over numpy: 0.5158
numexpr unaligned: 0.06492 Speed-up of numexpr unaligned over numpy: 0.6493
******************* Expression: i2**2 + (f3+1)**-2.5 < 3
numpy: 0.32493
numpy strided: 0.33087
numpy unaligned: 0.35109
numexpr: 0.05999 Speed-up of numexpr over numpy: 5.4164
numexpr strided: 0.06683 Speed-up of numexpr strided over numpy: 4.9509
numexpr unaligned: 0.07455 Speed-up of numexpr unaligned over numpy: 4.7095
******************* Expression: (f3+1)**50 > i2
numpy: 0.30474
numpy strided: 0.31431
numpy unaligned: 0.3192
numexpr: 0.05154 Speed-up of numexpr over numpy: 5.9127
numexpr strided: 0.06164 Speed-up of numexpr strided over numpy: 5.0991
numexpr unaligned: 0.06035 Speed-up of numexpr unaligned over numpy: 5.2891
******************* Expression: sqrt(i2**2 + f3**2) > 1
numpy: 0.06741
numpy strided: 0.07349
numpy unaligned: 0.09405
numexpr: 0.04676 Speed-up of numexpr over numpy: 1.4416
numexpr strided: 0.05361 Speed-up of numexpr strided over numpy: 1.3708
numexpr unaligned: 0.0615 Speed-up of numexpr unaligned over numpy: 1.5293
******************* Expression: (i2>2) | ((f3**2>3) & ~(i2*f3<2))
numpy: 0.05085
numpy strided: 0.06494
numpy unaligned: 0.08386
numexpr: 0.04527 Speed-up of numexpr over numpy: 1.1233
numexpr strided: 0.05323 Speed-up of numexpr strided over numpy: 1.22
numexpr unaligned: 0.06087 Speed-up of numexpr unaligned over numpy: 1.3777

*************** TOTALS **************************
numpy total: 1.0263
numpy strided total: 1.11778
numpy unaligned total: 1.25977
numexpr total: 0.59291
Speed-up of numexpr over numpy: 1.731
numexpr strided total: 0.6722
Speed-up of numexpr strided over numpy: 1.663
numexpr unaligned total: 0.72325
Speed-up of numexpr unaligned over numpy: 1.742
-------------- next part --------------
Python version:    2.5 (r25:51908, Nov  3 2006, 12:01:01) 
[GCC 4.0.2 20050901 (prerelease) (SUSE Linux)]
NumPy version:     1.0.3
******************* Expression: i2 > 0
numpy: 0.00315
numpy strided: 0.007
numpy unaligned: 0.01252
numexpr: 0.00385 Speed-up of numexpr over numpy: 0.8182
numexpr strided: 0.00738 Speed-up of numexpr strided over numpy: 0.9485
numexpr unaligned: 0.00886 Speed-up of numexpr unaligned over numpy: 1.4131
******************* Expression: i2 < 0
numpy: 0.00316
numpy strided: 0.00699
numpy unaligned: 0.01246
numexpr: 0.00377 Speed-up of numexpr over numpy: 0.8382
numexpr strided: 0.00742 Speed-up of numexpr strided over numpy: 0.942
numexpr unaligned: 0.00886 Speed-up of numexpr unaligned over numpy: 1.4063
******************* Expression: i2 < f3
numpy: 0.00876
numpy strided: 0.01584
numpy unaligned: 0.02571
numexpr: 0.00821 Speed-up of numexpr over numpy: 1.067
numexpr strided: 0.01 Speed-up of numexpr strided over numpy: 1.584
numexpr unaligned: 0.01348 Speed-up of numexpr unaligned over numpy: 1.9073
******************* Expression: i2-10 < f3
numpy: 0.01578
numpy strided: 0.02121
numpy unaligned: 0.03416
numexpr: 0.01004 Speed-up of numexpr over numpy: 1.5717
numexpr strided: 0.01181 Speed-up of numexpr strided over numpy: 1.7959
numexpr unaligned: 0.0153 Speed-up of numexpr unaligned over numpy: 2.2327
******************* Expression: i2*f3+f3*f3 > i2
numpy: 0.05065
numpy strided: 0.06868
numpy unaligned: 0.09667
numexpr: 0.01507 Speed-up of numexpr over numpy: 3.361
numexpr strided: 0.01651 Speed-up of numexpr strided over numpy: 4.1599
numexpr unaligned: 0.02024 Speed-up of numexpr unaligned over numpy: 4.7762
******************* Expression: 0.1*i2 > arctan2(i2, f3)
numpy: 0.13315
numpy strided: 0.14904
numpy unaligned: 0.1584
numexpr: 0.10897 Speed-up of numexpr over numpy: 1.2219
numexpr strided: 0.11178 Speed-up of numexpr strided over numpy: 1.3333
numexpr unaligned: 0.1155 Speed-up of numexpr unaligned over numpy: 1.3714
******************* Expression: i2%2 > 3
numpy: 0.03276
numpy strided: 0.03383
numpy unaligned: 0.04211
numexpr: 0.02611 Speed-up of numexpr over numpy: 1.2547
numexpr strided: 0.02713 Speed-up of numexpr strided over numpy: 1.247
numexpr unaligned: 0.03105 Speed-up of numexpr unaligned over numpy: 1.3562
******************* Expression: i2%10 < 4
numpy: 0.03251
numpy strided: 0.03397
numpy unaligned: 0.04227
numexpr: 0.02618 Speed-up of numexpr over numpy: 1.2418
numexpr strided: 0.02714 Speed-up of numexpr strided over numpy: 1.2517
numexpr unaligned: 0.03103 Speed-up of numexpr unaligned over numpy: 1.3622
******************* Expression: i2**2 + (f3+1)**-2.5 < 3
numpy: 0.32202
numpy strided: 0.32757
numpy unaligned: 0.34797
numexpr: 0.04053 Speed-up of numexpr over numpy: 7.9452
numexpr strided: 0.04199 Speed-up of numexpr strided over numpy: 7.8011
numexpr unaligned: 0.04577 Speed-up of numexpr unaligned over numpy: 7.6026
******************* Expression: (f3+1)**50 > i2
numpy: 0.30238
numpy strided: 0.3119
numpy unaligned: 0.31825
numexpr: 0.03251 Speed-up of numexpr over numpy: 9.3011
numexpr strided: 0.02719 Speed-up of numexpr strided over numpy: 11.4711
numexpr unaligned: 0.04017 Speed-up of numexpr unaligned over numpy: 7.9226
******************* Expression: sqrt(i2**2 + f3**2) > 1
numpy: 0.06747
numpy strided: 0.07415
numpy unaligned: 0.09568
numexpr: 0.02703 Speed-up of numexpr over numpy: 2.4961
numexpr strided: 0.02877 Speed-up of numexpr strided over numpy: 2.5773
numexpr unaligned: 0.0321 Speed-up of numexpr unaligned over numpy: 2.9807
******************* Expression: (i2>2) | ((f3**2>3) & ~(i2*f3<2))
numpy: 0.05395
numpy strided: 0.06548
numpy unaligned: 0.08676
numexpr: 0.02541 Speed-up of numexpr over numpy: 2.1232
numexpr strided: 0.02681 Speed-up of numexpr strided over numpy: 2.4424
numexpr unaligned: 0.03101 Speed-up of numexpr unaligned over numpy: 2.7978

*************** TOTALS **************************
numpy total: 1.02574
numpy strided total: 1.11566
numpy unaligned total: 1.27296
numexpr total: 0.32768
Speed-up of numexpr over numpy: 3.13
numexpr strided total: 0.34393
Speed-up of numexpr strided over numpy: 3.244
numexpr unaligned total: 0.39337
Speed-up of numexpr unaligned over numpy: 3.236
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boolean_timing.py
Type: application/x-python
Size: 4606 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071031/ebcdc934/attachment-0001.bin 


More information about the Numpy-discussion mailing list