Skip to content

Instantly share code, notes, and snippets.

@Ddedalus
Created December 10, 2019 20:45
Show Gist options
  • Save Ddedalus/9c789a9a1326642f4eb909bd0683df52 to your computer and use it in GitHub Desktop.
Save Ddedalus/9c789a9a1326642f4eb909bd0683df52 to your computer and use it in GitHub Desktop.
VSCode Jupyter slowdown tester
'''
WARNING: This script emulates mouse and keyboard.
To abort the emulation, move your MOUSE to the TOP LEFT CORNER of the screen.
Usage:
1. Create an empty Python file and start the interactive window (let it load).
2. With mouse over the new file, use a keyboard shortcut to open a terminal and excute this file with python.
3. The script will remove all contents from your empty file and start
writing the same cell over and ove again and executing it with the
ctrl + enter shortcut.
4. Observe how long it takes for the cells to execute in the interactive window.
To test clearing the cells from time to time modify the line below `if n % 10 == 0:` to use your shortcut.
'''
import time
import pyautogui
pyautogui.PAUSE = 0.1
# clear the workbench file and produce a header
pyautogui.click()
pyautogui.hotkey('ctrl', 'a')
pyautogui.press(['del'])
pyautogui.typewrite('# %%\n')
pyautogui.hotkey('shift', 'enter')
pyautogui.click(pause=2)
for n in range(1000):
pyautogui.typewrite(
'\n#%%'
'\n%%time '
'\nvar' + str(n) + ' '
'= [i**10 % 17 for i in range(100000)]\n'
'',
interval=0.05,
)
pyautogui.hotkey('ctrl', 'enter')
if n % 10 == 0:
# clear the output and wait from time to time
# MODIFY below:
# pyautogui.hotkey('ctrl', 'shift', 'del')
time.sleep(3)
print('Done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment