Skip to content

Instantly share code, notes, and snippets.

@mishailovic
Created May 30, 2021 07:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mishailovic/3bc25bb644642acf371e732f2dafa52f to your computer and use it in GitHub Desktop.
Save mishailovic/3bc25bb644642acf371e732f2dafa52f to your computer and use it in GitHub Desktop.
from pyrogram import Client
import time
from telethon.sync import TelegramClient, events
api_id = 123465
api_hash = "0123456789abcdef0123456789abcdef"
bot_token = "12345:0123456789abcdef0123456789abcdef"
file = "test.bin" # generate with $ truncate -s 1500M test.bin
username = "onetimeusername" # username to send test files.
pyroapp = Client("pyrogram", api_id, api_hash)
teleapp = TelegramClient('telethon', api_id, api_hash).start(bot_token=bot_token)
async def main():
async with pyroapp:
s = time.time()
m = await pyroapp.send_document(username, document = file)
e = time.time() - s
print(f"Pyrogram stats: speed - {1500 / e * 8:.2f} Mbps, time - {round(e)} s")
pyroapp.run(main())
async def telesend():
s = time.time()
m = await teleapp.send_file(username, file)
e = time.time() - s
print(f"Telethon stats: speed - {1500 / e * 8:.2f} Mbps, time - {round(e)} s")
with teleapp:
teleapp.loop.run_until_complete(telesend())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment