16 Ekim 2008 Perşembe

Hash That Diectory - Case Study

Hash That Directory - Use Case

In my spare time i try to finish my pysigner software. My aim for that project was to make a tool similar to keytool (Java). Therefore someone who needs
to add that X.509 stuff in its application can use my pysigner. One of the part that i'm writting now is to collect the sha1sums of a directory so i can sign verify the contents of that directory.
Computing the hashes is really easy you get some data in buffer and call the sha.update() method and then you have the hash. Firstly i have written that
part in normal way. By normal i mean without using threads. After that i thought it would be better to use threads for that purpose because most of the time we do IO operations. That way the python thread manager will switch when i read into buffer and will do the computation in another one ,cool isnt it ? Actually i was expecting a very big difference in times between normal and threaded implementation. Ok talk is cheap give the code and times :

Normal implementation :
[makkalot@acerfedora pysign]$ time python top_level.py
Straight Tester ...

real 9m52.081s
user 2m23.076s
sys 0m51.895s

4 THreaded implemenatation:
[makkalot@acerfedora pysign]$ time python top_level.py
4 Threadded Tester ...

real 10m7.411s
user 1m50.216s
sys 0m42.488s


8 Threaded implementation:
[makkalot@acerfedora pysign]$ time python top_level.py
8 Threadded Tester ...

real 10m23.042s
user 2m42.285s
sys 0m59.676s


The results are really strange are the Python threads a big illusion ? Sometimes i think they are like mastubation nothing real at all :)
BTW, if someone finds a bug and thinks it can be improved plz comment ...

Here is the normal implementation :
Link :
Here is the theraded part :
Link :

Hiç yorum yok: