31 lines
827 B
Python
31 lines
827 B
Python
from CoreAlgorithm import *
|
|
from memory_profiler import profile
|
|
import threading
|
|
from some_decorators import track_performance
|
|
|
|
@track_performance
|
|
def time_memory_explain_test():
|
|
Public_Key, Private_Key = generate_paillier_keypair() # 随机生成1024长的公钥和私钥
|
|
x = 90000424.23
|
|
y = 90849442
|
|
x_encrypted = Public_Key.encrypt(x) # 加密后的x
|
|
y_encrypted = Public_Key.encrypt(y) # 加密后的y
|
|
t_encrypted = (x_encrypted + y_encrypted * 0.5)
|
|
Private_Key.decrypt(t_encrypted)
|
|
|
|
|
|
@profile()
|
|
def multi_thread_test():
|
|
threads = []
|
|
# 创建并启动5个线程
|
|
for i in range(20):
|
|
t = threading.Thread(target=time_memory_explain_test)
|
|
threads.append(t)
|
|
t.start()
|
|
|
|
# 等待所有线程完成
|
|
for t in threads:
|
|
t.join()
|
|
|
|
|
|
multi_thread_test() |