v1.0
This commit is contained in:
		
							
								
								
									
										82
									
								
								test.py
									
									
									
									
									
								
							
							
						
						
									
										82
									
								
								test.py
									
									
									
									
									
								
							@@ -1,80 +1,2 @@
 | 
				
			|||||||
import asyncio
 | 
					a = [1]
 | 
				
			||||||
import time
 | 
					print(a[:1], a[1:])
 | 
				
			||||||
 | 
					 | 
				
			||||||
from limiter import BatchLimiter
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test1():
 | 
					 | 
				
			||||||
    limiter = BatchLimiter()
 | 
					 | 
				
			||||||
    cnt = 0
 | 
					 | 
				
			||||||
    for i in range(100):
 | 
					 | 
				
			||||||
        await limiter.acquire_ozon('denco')
 | 
					 | 
				
			||||||
        cnt += 1
 | 
					 | 
				
			||||||
        print('ozon denco-1', cnt)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test2():
 | 
					 | 
				
			||||||
    limiter = BatchLimiter()
 | 
					 | 
				
			||||||
    cnt = 0
 | 
					 | 
				
			||||||
    for i in range(100):
 | 
					 | 
				
			||||||
        await limiter.acquire_ozon('denco')
 | 
					 | 
				
			||||||
        cnt += 1
 | 
					 | 
				
			||||||
        print('ozon denco-2', cnt)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test3():
 | 
					 | 
				
			||||||
    limiter = BatchLimiter()
 | 
					 | 
				
			||||||
    cnt = 0
 | 
					 | 
				
			||||||
    for i in range(100):
 | 
					 | 
				
			||||||
        await limiter.acquire_wildberries('denco')
 | 
					 | 
				
			||||||
        cnt += 1
 | 
					 | 
				
			||||||
        print('wb denco-1', cnt)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test4():
 | 
					 | 
				
			||||||
    limiter = BatchLimiter()
 | 
					 | 
				
			||||||
    cnt = 0
 | 
					 | 
				
			||||||
    for i in range(100):
 | 
					 | 
				
			||||||
        await limiter.acquire_wildberries('denco')
 | 
					 | 
				
			||||||
        cnt += 1
 | 
					 | 
				
			||||||
        print('wb denco-2', cnt)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test5():
 | 
					 | 
				
			||||||
    limiter = BatchLimiter()
 | 
					 | 
				
			||||||
    cnt = 0
 | 
					 | 
				
			||||||
    for i in range(100):
 | 
					 | 
				
			||||||
        await limiter.acquire_wildberries('denco')
 | 
					 | 
				
			||||||
        cnt += 1
 | 
					 | 
				
			||||||
        print('wb denco-2', cnt)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test6():
 | 
					 | 
				
			||||||
    limiter = BatchLimiter()
 | 
					 | 
				
			||||||
    cnt = 0
 | 
					 | 
				
			||||||
    for i in range(100):
 | 
					 | 
				
			||||||
        await limiter.acquire_ozon('bolgov')
 | 
					 | 
				
			||||||
        cnt += 1
 | 
					 | 
				
			||||||
        print('wb bolgov-1', cnt)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async def test():
 | 
					 | 
				
			||||||
    start = time.time()
 | 
					 | 
				
			||||||
    await asyncio.gather(*[
 | 
					 | 
				
			||||||
        test1(),
 | 
					 | 
				
			||||||
        # test2(),
 | 
					 | 
				
			||||||
        # test3(),
 | 
					 | 
				
			||||||
        # test4(),
 | 
					 | 
				
			||||||
        # test5(),
 | 
					 | 
				
			||||||
        # test6(),
 | 
					 | 
				
			||||||
    ])
 | 
					 | 
				
			||||||
    print(time.time() - start)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def main():
 | 
					 | 
				
			||||||
    loop = asyncio.get_event_loop()
 | 
					 | 
				
			||||||
    loop.run_until_complete(test())
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if __name__ == '__main__':
 | 
					 | 
				
			||||||
    main()
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user