MrPiada / ChessRepertoireGenerator

MIT License
1 stars 0 forks source link

correct usage of lichess api #30

Closed MrPiada closed 1 year ago

MrPiada commented 1 year ago

That's critical...and very very stupid.... I tried to profile the software and i got:

Wed Aug 16 21:40:22 2023    builder.prof

         1242615 function calls (1228231 primitive calls) in 15.201 seconds

   Ordered by: internal time
   List reduced from 4815 to 30 due to restriction <30>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       57    5.324    0.093    5.324    0.093 {method 'read' of '_ssl._SSLSocket' objects}
       57    4.386    0.077    4.386    0.077 {method 'do_handshake' of '_ssl._SSLSocket' objects}
       57    3.761    0.066    3.761    0.066 {method 'connect' of '_socket.socket' objects}
       57    0.537    0.009    0.537    0.009 {method 'load_verify_locations' of '_ssl._SSLContext' objects}

That's because I've opened and closed the socket at each call to the lichess api....that's crazy and super stupid. Just fix it !

https://github.com/lichess-org/berserk