HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
ftest_crc32.py
Go to the documentation of this file.
1 #coding: utf-8
2 '''
3 HCE project, Python bindings, DC dependencies
4 The crc32 collisions research tests.
5 
6 @package: dc
7 @author bgv bgv.hce@gmail.com
8 @link: http://hierarchical-cluster-engine.com/
9 @copyright: Copyright © 2015 IOIX Ukraine
10 @license: http://hierarchical-cluster-engine.com/license/
11 @since: 0.1
12 '''
13 
14 
15 import ctypes
16 import zlib
17 import socket
18 import time
19 import uuid
20 import binascii
21 
22 _connection_uid = 'AAA'
23 print socket.gethostname() + "-" + str(time.time()) + "-" + uuid.uuid1().hex + "-" + str(_connection_uid)
24 
25 h = {}
26 t = time.time()
27 s1 = socket.gethostname() + "-"
28 s2 = "-" + uuid.uuid1().hex + "-" + str(_connection_uid)
29 i = 1
30 j = 0
31 maxItr = 10000000
32 while True :
33  ts = str(t)
34  #ts = s1 + str(t) + s2
35  ts = str(ctypes.c_uint32(zlib.crc32(ts, int(time.time()))).value)
36  #ts = str(ctypes.c_uint32(binascii.crc32(ts)).value)
37  if ts in h:
38  h[ts] += 1
39  j += 1
40  #print str(t) + "\n"
41  else:
42  h[ts] = 1
43  t -= 1
44  i += 1
45  if t < 0 or i > maxItr:
46  break
47 
48 print "Finished: " + str(i) + " iterations, " + str(j) + " collisions, hash len: " + str(len(h))
49