This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
services: | |
postgres: | |
container_name: postgres | |
image: postgres:14-bullseye | |
environment: | |
POSTGRES_PASSWORD: password | |
volumes: | |
- "./postgres/socket:/var/run/postgresql" | |
app: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
from time import sleep, time_ns | |
class ServerThread(Thread): | |
def __init__(self): | |
Thread.__init__(self) | |
self.alive = True | |
self.last_loop_time = 0 | |
def run(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run(self): | |
while True: | |
before_ts = time_ns() | |
for num in range(0, 1000): | |
print(num) | |
after_ts = time_ns() | |
print('loop time: ' + str(after_ts - before_ts)) | |
sleep(1) | |
print('loop complete') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
from time import sleep | |
class ServerThread(Thread): | |
def __init__(self): | |
Thread.__init__(self) | |
def run(self): | |
while True: | |
for num in range(0, 1000): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
from time import sleep | |
class ServerThread(Thread): | |
def __init__(self): | |
Thread.__init__(self) | |
def run(self): | |
while True: | |
sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time_ns | |
before_ts = time_ns() | |
for num in range(0, 1000): | |
print(num) | |
after_ts = time_ns() | |
diff = after_ts - before_ts | |
print('loop time in \n' \ | |
'nanoseconds: ' + str(diff) + '\n' + \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time_ns | |
before_ts = time_ns() | |
for num in range(0, 1000): | |
pass | |
after_ts = time_ns() | |
diff = after_ts - before_ts | |
print('loop time in \n' \ | |
'nanoseconds: ' + str(diff) + '\n' + \ |