mirror of
https://github.com/Llloooggg/DDoS.git
synced 2026-03-06 10:06:23 +03:00
Улучшение кода
This commit is contained in:
22
__init__.py
22
__init__.py
@@ -63,11 +63,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
subUrls = url_grab(url)
|
subUrls = url_grab(url)
|
||||||
|
|
||||||
speed = input(datetime.now().strftime(
|
speed = input(f'{datetime.now().strftime("[%X]")} Введите скорость запросов(з/с) или оставьте пустым для максимальной: ')
|
||||||
'[%X] ') + 'Введите скорость запросов(з/с) или оставьте пустым для максимальной: ')
|
requestCount = int(input(f'{datetime.now().strftime("[%X]")} Введите число запросов: '))
|
||||||
requestCount = int(input(datetime.now().strftime(
|
|
||||||
'[%X] ') + 'Введите число запросов: '))
|
|
||||||
print()
|
|
||||||
|
|
||||||
requestCountExecuted = 0
|
requestCountExecuted = 0
|
||||||
requestCountSuccess = 0
|
requestCountSuccess = 0
|
||||||
@@ -75,7 +72,7 @@ if __name__ == '__main__':
|
|||||||
with progressbar.ProgressBar(max_value=requestCount) as bar:
|
with progressbar.ProgressBar(max_value=requestCount) as bar:
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
if speed:
|
if speed:
|
||||||
speed = int(speed)
|
speed = float(speed)
|
||||||
for i in range(requestCount):
|
for i in range(requestCount):
|
||||||
delayStartTime = time.time()
|
delayStartTime = time.time()
|
||||||
curUrl = random.choice(subUrls)
|
curUrl = random.choice(subUrls)
|
||||||
@@ -83,8 +80,8 @@ if __name__ == '__main__':
|
|||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
bar.update(requestCountExecuted)
|
bar.update(requestCountExecuted)
|
||||||
if time.time() - delayStartTime < 1 / speed:
|
while time.time() - delayStartTime < 1 / speed:
|
||||||
time.sleep(1 / speed - time.time() + delayStartTime)
|
pass
|
||||||
else:
|
else:
|
||||||
for i in range(requestCount):
|
for i in range(requestCount):
|
||||||
curUrl = random.choice(subUrls)
|
curUrl = random.choice(subUrls)
|
||||||
@@ -96,7 +93,8 @@ if __name__ == '__main__':
|
|||||||
while requestCountExecuted < requestCount:
|
while requestCountExecuted < requestCount:
|
||||||
bar.update(requestCountExecuted)
|
bar.update(requestCountExecuted)
|
||||||
|
|
||||||
print(datetime.now().strftime(
|
endTime = time.time() - startTime
|
||||||
'[%X] ') + 'Успешных запросов: ' + str(requestCountSuccess))
|
print(endTime)
|
||||||
print(datetime.now().strftime('[%X] ') + 'Средняя скорость: ' + str(
|
|
||||||
round(requestCountExecuted / (time.time() - startTime))) + ' з/с')
|
print(f'{datetime.now().strftime("[%X]")} Успешных запросов: {requestCountSuccess}')
|
||||||
|
print(f'{datetime.now().strftime("[%X]")} Средняя скорость: {round(requestCountExecuted / endTime, 2)} з/с')
|
||||||
|
|||||||
Reference in New Issue
Block a user