Open GoogleCodeExporter opened 8 years ago
Seems with new bitLength function (introduced in rev 4ced4b20f261) searching
with gmpy is no more preformant than native python. Using profile command (thx
Justin!) for benchmarking I got:
tamas@localhost:~/pychess/lib/pychess/Players/with-gmpy$ python print_pstats.py
Fri May 24 21:05:33 2013 rep.prof
668083275 function calls (665324580 primitive calls) in 488.063 CPU seconds
Ordered by: cumulative time
List reduced from 109 to 60 due to restriction <60>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 488.063 488.063 <string>:1(<module>)
1 0.003 0.003 488.063 488.063 /home/tamas/pychess/lib/pychess/Utils/lutils/Benchmark.py:29(benchmark)
1036890/80 11.367 0.000 487.904 6.099
/home/tamas/pychess/lib/pychess/Utils/lutils/lsearch.py:25(alphaBeta)
2637943/916058 15.350 0.000 401.346 0.000
/home/tamas/pychess/lib/pychess/Utils/lutils/lsearch.py:228(quiescent)
2449973 20.349 0.000 222.552 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:18(evaluateComplete)
134571369 66.588 0.000 84.828 0.000
/home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:132(iterBits)
4899946 25.705 0.000 69.212 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:108(evalKingTropism)
2791880 20.726 0.000 47.326 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:358(applyMove)
2346858 2.842 0.000 43.627 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lsort.py:8(getCaptureValue)
2791289 15.727 0.000 41.552 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:478(popMove)
1989260 15.821 0.000 40.785 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:156(staticExchangeEvaluate)
4899946 20.928 0.000 36.493 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:274(evalPawnStructure)
3129095 12.439 0.000 24.470 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:268(genCaptures)
7290312 16.693 0.000 22.549 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:306(_removePiece)
2449973 9.467 0.000 20.830 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:169(cacheablePawnInfo)
7290517 14.765 0.000 20.157 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:293(_addPiece)
4531407 13.484 0.000 19.916 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:55(getAttacks)
3674753 5.170 0.000 18.976 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldraw.py:77(test)
4899946 9.543 0.000 18.560 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:535(evalRooks)
6023811 13.863 0.000 16.615 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:11(isAttacked)
4899946 10.319 0.000 14.255 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:436(evalDev)
28985072 9.660 0.000 13.822 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:99(bitLength)
3783359 8.956 0.000 11.886 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lsort.py:22(getMoveValue)
2449973 8.473 0.000 11.832 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:42(evalMaterial)
79684035 11.712 0.000 11.712 0.000 {method 'popcount' of 'mpz' objects}
3674925 3.172 0.000 10.973 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:276(isChecked)
84677299 10.810 0.000 10.810 0.000 {method 'scan1' of 'mpz' objects}
4899946 6.422 0.000 10.185 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:479(evalBishops)
4899946 7.151 0.000 10.122 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:388(evalKing)
3812285 4.075 0.000 9.348 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:112(genAllMoves)
2431315 2.425 0.000 9.146 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:282(opIsChecked)
992931 2.416 0.000 9.127 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:475(genCheckEvasions)
2449973 6.630 0.000 8.498 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:157(probePawns)
30031517 8.314 0.000 8.314 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:41(clearBit)
3674753 5.251 0.000 7.264 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:52(repetitionCount)
1036740 5.727 0.000 7.203 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/TranspositionTable.py:39(probe)
4899946 4.837 0.000 7.011 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:374(evalDoubleQR7)
3536513 1.881 0.000 6.564 0.000 {sum}
9188981 4.180 0.000 5.815 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:52(firstBit)
21871551 5.392 0.000 5.392 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:30(setBit)
3674603 2.856 0.000 5.357 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldraw.py:34(testMaterial)
2449973 3.704 0.000 3.704 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:504(evalTrappedBishops)
6576294 3.410 0.000 3.410 0.000 {method 'unpack_from' of 'Struct' objects}
3063529 2.628 0.000 3.405 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:254(addXrayPiece)
4085965 1.568 0.000 3.075 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:317(<genexpr>)
5583185 2.897 0.000 2.897 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:318(setColor)
22330312 2.853 0.000 2.853 0.000 {method 'pop' of 'list' objects}
9332250 2.550 0.000 2.550 0.000 {max}
17010822 2.524 0.000 2.524 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldata.py:7(FILE)
25106285 2.307 0.000 2.307 0.000 {method 'append' of 'list' objects}
6843249 2.174 0.000 2.174 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:22(newMove)
6023645 2.039 0.000 2.039 0.000 {min}
9188981 1.635 0.000 1.635 0.000 {method 'numdigits' of 'mpz' objects}
1405101 0.627 0.000 1.608 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:366(<genexpr>)
2791896 1.401 0.000 1.401 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:337(setEnpassant)
3391260 1.346 0.000 1.346 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/TranspositionTable.py:81(isKiller)
2346858 1.308 0.000 1.308 0.000 {_heapq.heappush}
1745836 1.289 0.000 1.289 0.000 {_heapq.heappop}
3674603 1.185 0.000 1.185 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldraw.py:5(testFifty)
120639 1.176 0.000 1.176 0.000 {method 'sort' of 'list' objects}
tamas@localhost:~/pychess/lib/pychess/Players/no-gmpy$ python print_pstats.py
Fri May 24 21:14:11 2013 rep.prof
552166560 function calls (549407865 primitive calls) in 468.027 CPU seconds
Ordered by: cumulative time
List reduced from 107 to 60 due to restriction <60>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 468.027 468.027 <string>:1(<module>)
1 0.003 0.003 468.027 468.027 /home/tamas/pychess/lib/pychess/Utils/lutils/Benchmark.py:29(benchmark)
1036890/80 10.688 0.000 467.873 5.848
/home/tamas/pychess/lib/pychess/Utils/lutils/lsearch.py:25(alphaBeta)
2637943/916058 14.685 0.000 383.575 0.000
/home/tamas/pychess/lib/pychess/Utils/lutils/lsearch.py:228(quiescent)
2449973 20.137 0.000 210.332 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:18(evaluateComplete)
134571369 53.596 0.000 53.596 0.000
/home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:140(iterBits)
4899946 23.697 0.000 51.398 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:108(evalKingTropism)
2791880 19.880 0.000 46.515 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:358(applyMove)
2346858 2.751 0.000 42.462 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lsort.py:8(getCaptureValue)
2791289 14.567 0.000 40.462 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:478(popMove)
1989260 15.742 0.000 39.711 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:156(staticExchangeEvaluate)
28985072 14.905 0.000 38.417 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:123(bitLength)
4899946 19.252 0.000 32.633 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:274(evalPawnStructure)
3674753 4.931 0.000 24.651 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldraw.py:77(test)
7290312 16.079 0.000 23.119 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:306(_removePiece)
7290517 14.510 0.000 20.109 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:293(_addPiece)
2449973 8.843 0.000 19.647 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:169(cacheablePawnInfo)
3129095 12.048 0.000 18.791 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:268(genCaptures)
4531407 13.939 0.000 18.549 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:55(getAttacks)
4899946 6.575 0.000 17.237 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:479(evalBishops)
28985072 16.312 0.000 16.312 0.000 {bin}
6023811 14.409 0.000 15.960 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:11(isAttacked)
4899946 9.237 0.000 15.953 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:535(evalRooks)
2449973 8.434 0.000 14.319 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:42(evalMaterial)
4899946 6.673 0.000 13.593 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:388(evalKing)
4899946 8.756 0.000 12.102 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:436(evalDev)
3783359 8.476 0.000 11.264 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lsort.py:22(getMoveValue)
3674603 2.758 0.000 11.094 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldraw.py:34(testMaterial)
3674925 3.112 0.000 10.789 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:276(isChecked)
4899946 5.175 0.000 9.813 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:374(evalDoubleQR7)
30031517 9.767 0.000 9.767 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:41(clearBit)
2431315 2.316 0.000 8.636 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:282(opIsChecked)
3812285 3.897 0.000 8.547 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:112(genAllMoves)
992931 2.341 0.000 8.434 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:475(genCheckEvasions)
3536513 1.870 0.000 7.618 0.000 {sum}
2449973 5.807 0.000 7.509 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:157(probePawns)
3674753 5.502 0.000 7.458 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:52(repetitionCount)
28985072 7.200 0.000 7.200 0.000 {method 'count' of 'str' objects}
1036740 5.518 0.000 6.930 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/TranspositionTable.py:39(probe)
21871551 5.599 0.000 5.599 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:30(setBit)
9188981 5.418 0.000 5.418 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/bitboard.py:56(firstBit)
4085965 1.480 0.000 4.656 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:317(<genexpr>)
3063529 2.716 0.000 3.560 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/attack.py:254(addXrayPiece)
2449973 3.500 0.000 3.500 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:504(evalTrappedBishops)
6576294 3.175 0.000 3.175 0.000 {method 'unpack_from' of 'Struct' objects}
5583185 2.821 0.000 2.821 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:318(setColor)
22330312 2.683 0.000 2.683 0.000 {method 'pop' of 'list' objects}
17010822 2.469 0.000 2.469 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldata.py:7(FILE)
25106285 2.169 0.000 2.169 0.000 {method 'append' of 'list' objects}
9332250 2.060 0.000 2.060 0.000 {max}
6023645 1.922 0.000 1.922 0.000 {min}
6843249 1.899 0.000 1.899 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/lmovegen.py:22(newMove)
2791896 1.341 0.000 1.341 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/LBoard.py:337(setEnpassant)
3391260 1.278 0.000 1.278 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/TranspositionTable.py:81(isKiller)
1745836 1.189 0.000 1.189 0.000 {_heapq.heappop}
3674603 1.169 0.000 1.169 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/ldraw.py:5(testFifty)
120639 1.159 0.000 1.159 0.000 {method 'sort' of 'list' objects}
2346858 1.153 0.000 1.153 0.000 {_heapq.heappush}
1405101 0.579 0.000 1.092 0.000 /home/tamas/pychess/lib/pychess/Utils/lutils/leval.py:366(<genexpr>)
2065763 0.884 0.000 0.884 0.000 {range}
Original comment by gbtami
on 24 May 2013 at 8:44
Removed gmpy in rev #83e1de93438c
Original comment by gbtami
on 24 May 2013 at 9:47
Hi. I maintain gmpy and found this issue via a Google search. I've released a
new version called gmpy2 that contains some enhancements that may improve the
performance relative to gmpy. There is a new mutable (!) integer type called
xmpz that supports better bit access. Assuming X is an xmpz instance, you do
the following:
X.iter_set() -> creates a generator that returns the bit positions that are set
X[7] = 1 -> set bit 8 (count starts with 0) to 1
Feel free to contact me if you have any questions.
casevh
Original comment by casevh
on 31 May 2013 at 5:20
@casevh, thx. for the info! I will try gmpy2.
Original comment by gbtami
on 31 May 2013 at 9:29
Original issue reported on code.google.com by
gbtami
on 24 May 2013 at 8:28