|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- # # # import timeit
- # # # class MyClass:
- # # # @staticmethod
- # # # def my_static_method():
- # # # pass
- # # # def my_function():
- # # # pass
- # # # # 通过类名调用静态方法
- # # # def test_static_method():
- # # # MyClass.my_static_method()
- # # # # 通过函数名调用函数方法
- # # # def test_function():
- # # # my_function()
- # # # # 测试执行速度
- # # # print("static method: ", timeit.timeit(test_static_method, number=10000000))
- # # # print("function: ", timeit.timeit(test_function, number=10000000))
- # # import copy
- # # import os
- # # import pickle
- # # import time
- # # import timeit
- # # import traceback
- # # from collections import namedtuple
- # # from concurrent.futures import ThreadPoolExecutor
- # # from multiprocessing import Queue
- # # from threading import Thread
- # #
- # # import cv2
- # # import psutil
- # #
- # # # def mu():
- # # # aa ={
- # # # 'half': 1,
- # # # 'iou_thres': (1,2,3),
- # # # 'allowedList': [1,3],
- # # # 'aa': {"1":"2"},
- # # # }
- # # # bb = aa.copy()
- # # # def mu1():
- # # # aa ={
- # # # 'half': 1,
- # # # 'iou_thres': (1,2,3),
- # # # 'allowedList': [1,3],
- # # # 'aa': {"1":"2"},
- # # # }
- # # # # copy.deepcopy(aa)
- # # # print(pickle.loads(pickle.dumps(aa)))
- # # # mu1()
- # # # print("static method1: ", timeit.timeit(mu, number=100000))
- # # # print("static method2: ", timeit.timeit(mu1, number=100000))
- # #
- # #
- # # # def aa():
- # # # Point = namedtuple('Point', ('x', 'y', 'z'))
- # # # aa = Point("1111111111", "22222222222", "333333333333")
- # # # aa.x
- # # # aa.y
- # # # aa.z
- # # # def aa1():
- # # # aa = ["1111111111", "22222222222", "333333333333"]
- # # # aa[0]
- # # # aa[1]
- # # # aa[2]
- # # # print("static method1: ", timeit.timeit(aa, number=100000))
- # # # print("static method2: ", timeit.timeit(aa1, number=100000))
- # # # aa=[]
- # # # aa[28] = "11111"
- # # # print(aa)
- # # # def aa1():
- # # # # 获取当前进程的父进程的PID
- # # # if psutil.pid_exists(psutil.Process(os.getpid()).ppid()):
- # # # print("11111")
- # # # else:
- # # # print("2222")
- # # # print("static method2: ", timeit.timeit(aa1, number=100))
- # # # def aa():
- # # # num=1
- # # # while num < 100:
- # # # num+=1
- # # # time.sleep(100)
- # # # dd = Thread(target=aa, args=())
- # # # dd.setDaemon(True)
- # # # dd.start()
- # # # try:
- # # # dd.join(1)
- # # # except Exception:
- # # # print(traceback.format_exc())
- # # # a = Queue()
- # # # aa = {"aa": "11"}
- # # # a.put(aa)
- # # # bb = a.get()
- # # # bb["aa"] = "2222"
- # # # print(aa)
- # # # print(bb)
- # #
- # #
- # # # def dd():
- # # # w = ["1111", "2222", "3333"]
- # # # a = w[2]
- # # #
- # # #
- # # # def cc():
- # # # aa = {"aa": "1111", "bb": "2222", "cc": "3333"}
- # # # t= aa["cc"]
- # # #
- # # # print("static method1: ", timeit.timeit(dd, number=1000))
- # # # print("static method2: ", timeit.timeit(cc, number=1000))
- # # import numpy as np
- # #
- # #
- # # # # 创建一个numpy数组
- # # # arr1 = np.array([[[1,2,3]], [[2,3, 4]]])
- # # # # 使用copy()方法深度拷贝数组
- # # # arr2 = arr1.copy()
- # # # # 修改arr2中的元素
- # # # arr2[0][0][1] = 5
- # # # # 打印arr1和arr2
- # # # print("arr1:", arr1)
- # # # print("arr2:", arr2)
- # # # def cop2():
- # # # arr1 = np.array([[1, 2], [3, 4]])
- # # # arr2 = arr1
- # # # def cop():
- # # # arr1 = np.array([[1, 2], [3, 4]])
- # # # arr2 = arr1.copy()
- # # # def cop1():
- # # # arr1 = np.array([[1, 2], [3, 4]])
- # # # arr2 = copy.deepcopy(arr1)
- # # # print("static method1: ", timeit.timeit(cop2, number=1000))
- # # # print("static method1: ", timeit.timeit(cop, number=1000))
- # # # print("static method2: ", timeit.timeit(cop1, number=1000))
- # #
- # # # aa = {}
- # # # def dd(aa):
- # # # aa["aa"] = 1
- # # #
- # # # dd(aa)
- # # # print(aa)
- # #
- # # def aa(num):
- # # while True:
- # # time.sleep(4)
- # # num+= 1
- # # raise Exception("1111")
- # #
- # #
- # # def dd():
- # # num = 1
- # # with ThreadPoolExecutor(max_workers=1) as t:
- # # ddd = t.submit(aa, num)
- # # while True:
- # # ddd.result()
- # # time.sleep(1)
- # # print(num)
- # #
- # # image = cv2.imread(r'D:\tuoheng\codenew\tuoheng_alg\image\logo.png')
- # # image1 = np.array(image)
- # # or_result, or_image = cv2.imencode(".jpg", image1)
- # # aa = or_image.tobytes()
- # #
- # # numpy_array = np.frombuffer(aa, dtype=np.uint8)
- # # img_bgr = cv2.cvtColor(numpy_array, cv2.COLOR_RGB2BGR)
- # # cv2.sh
- # # print(img_bgr)
- # import os
- # import time
- # from os import getpid
- #
- # import psutil
- #
- #
- # from multiprocessing import Process
- #
- # def fun2(name, pid):
- # while True:
- # time.sleep(1)
- # print("fun2", getpid(), os.getppid(), psutil.Process(getpid()).ppid(), psutil.pid_exists(psutil.Process(getpid()).ppid()))
- #
- # def fun1(name):
- # print('测试%s多进程' %name)
- # p = Process(target=fun2,args=('Python',getpid(),)) #实例化进程对象
- # # p.daemon = True
- # p.start()
- # print("funn1", getpid(), p.pid)
- #
- #
- #
- # if __name__ == '__main__':
- # p = Process(target=fun1,args=('Python',)) #实例化进程对象
- # # p.daemon = True
- # p.start()
- #
- #
- # print('结束测试', os.getpid())
- #
- listeningProcesses={"11111": "1111", "2222": "2222"}
-
- p = list(listeningProcesses.keys())
- p.reverse()
- print(p)
|