[ TAG 141 ][09.09.2021] -Erfolgreich -IAP-20210601-20210722-1145

Ich beginne mit der Worksession. Mein erster Anhaltspunkt ist der Beitrag [T133].

In dieser WORKSESSION werde ich mich um die Performance-Tests kümmern. Ich denke es ist schon wichtig zu wissen, welches Verfahren, wie viel Rechen-Ressourcen verbraucht.


  1. Messung:
    • Wie viele Schleifendurchgänge werden innerhalb einer Nanosekunde erzielt?
      • Ergebnis:
      • Durch Messung habe ich herausgefunden, dass ich die Zeit ca. eine Mikrosekunde genau messen kann.
      • Mein Messbarer Wert befindet sich zwischen 7.700 bis 7.800 Schleifendurchläufen. Das Zeigte mir die Siebte und Achte Zeitmessung.
      • Auf Nano-Sekunden-Ebene kann ich mit Python nicht messen.
      • Bei der achten Messung haben wir 7.800 Schleifendurchläufe und eine Zeitmessung von 997.300 Nanosekunden.
      • 997.300 Nanosekunden sind 997 Mikrosekunden und 0,9 Millisekunden
      • Erste, zweite, dritte Zeitmessung zeigen folgende Gesetzmäßigkeiten
        • Messbare Zeitdifferenz befindet sich bei 997 Mikrosekunden
        • Innerhalb der messbaren Zeitdifferenz werden ca 8.000 Schleifendurchläufe registriert
        • Ich habe errechnet, dass ein Schleifendurchlauf ca. 120 Nanosekunden beträgt. Die 120 Nanosekunden lassen sich jedoch nicht messen, weil die [time.time_ns()]-Methode nicht so schnell reagieren kann. Ein Schleifendurchlauf ist ca. 8000 mal schneller als die[time.time_ns()]-Methode.

# Erste Zeitmessung
tm0 = time.time_ns()
tm1 = 0
dummy = True
i = 0
while dummy:
i += 1
if tm0 != time.time_ns():
tm1 = time.time_ns()
dummy = False
print("Erste Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1-tm0}")
print(f"(tm1-tm0)//i = {(tm1 - tm0) / i}")
print("")

# Zweite Zeitmessung
tm0 = time.time_ns()
tm1 = 0
dummy = True
i = 0
while dummy:
i += 1
if tm0 != time.time_ns():
tm1 = time.time_ns()
dummy = False
print("Zweite Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)//i = {(tm1 - tm0) / i}")
print("")

# Dritte Zeitmessung
tm0 = time.time_ns()
tm1 = 0
dummy = True
i = 0
while dummy:
i += 1
if tm0 != time.time_ns():
tm1 = time.time_ns()
dummy = False
print("Dritte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)//i = {(tm1 - tm0)/i}")
print("")

# Vierte Zeitmessung
dummy = True
i = 0
tm0 = time.time_ns()
while dummy:
i += 1
dummy = False
tm1 = time.time_ns()
print("Vierte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print("")

# Fünfte Zeitmessung
dummy = True
i = 0
tm0 = time.time_ns()
tm00 = 0
while dummy:
i += 1
tm00 = time.time_ns()
dummy = False
tm1 = time.time_ns()
print("Fünfte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm00: {tm00}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print("")

# Sechste Zeitmessung
dummy = True
i = 0
tm0 = time.time_ns()
tm00 = 0
while dummy:
i += 1
tm00 = time.time_ns()
if i == 7760:
dummy = False
tm1 = time.time_ns()
print("Sechste Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm00: {tm00}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print("")

# Siebte Zeitmessung
dummy = True
i = 0
tm0 = time.time_ns()
tm00 = 0
while dummy:
i += 1
tm00 = time.time_ns()
if i == 7700:
dummy = False
tm1 = time.time_ns()
print("Siebte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm00: {tm00}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print("")

# Achte Zeitmessung
dummy = True
i = 0
tm0 = time.time_ns()
tm00 = 0
while dummy:
i += 1
tm00 = time.time_ns()
if i == 7800:
dummy = False
tm1 = time.time_ns()
print("Achte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm00: {tm00}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print("")

AUSGABE:

Erste Zeitmessung
i: 3220
tm0: 1631148818144550600
tm1: 1631148818145547900
tm1-tm0 = 997300
(tm1-tm0)//i = 309.72049689440996

Zweite Zeitmessung
i: 8642
tm0: 1631148818145547900
tm1: 1631148818146544900
tm1-tm0 = 997000
(tm1-tm0)//i = 115.36681323767647

Dritte Zeitmessung
i: 8065
tm0: 1631148818146544900
tm1: 1631148818147542200
tm1-tm0 = 997300
(tm1-tm0)//i = 123.65778053316801

Vierte Zeitmessung
i: 1
tm0: 1631148818147542200
tm1: 1631148818147542200
tm1-tm0 = 0

Fünfte Zeitmessung
i: 1
tm0: 1631148818147542200
tm00: 1631148818147542200
tm1: 1631148818147542200
tm1-tm0 = 0

Sechste Zeitmessung
i: 7760
tm0: 1631148818147542200
tm00: 1631148818147542200
tm1: 1631148818147542200
tm1-tm0 = 0

Siebte Zeitmessung
i: 7700
tm0: 1631148818148539500
tm00: 1631148818148539500
tm1: 1631148818148539500
tm1-tm0 = 0

Achte Zeitmessung
i: 7800
tm0: 1631148818148539500
tm00: 1631148818149536800
tm1: 1631148818149536800
tm1-tm0 = 997300


Hier sind die Messungen vom SHM-Modul




# Erste Zeitmessung
tm0 = time.time_ns()
tm1 = time.time_ns()
i = 0
while GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR):
i += 1
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, False)
print("Erste Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1-tm0}")
print(f"(tm1-tm0)/i = {(tm1-tm0)/i}")
print("")
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, True)

# Zweite Zeitmessung
tm0 = time.time_ns()
tm1 = 0
i = 0
while GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR):
i += 1
if tm0 != time.time_ns():
tm1 = time.time_ns()
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, False)
print("Zweite Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)/i = {(tm1 - tm0) / i}")
print("")
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, True)

# Dritte Zeitmessung
tm0 = time.time_ns()
tm1 = 0
i = 0
while GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR):
i += 1
if tm0 != time.time_ns():
tm1 = time.time_ns()
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, False)
print("Dritte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)/i = {(tm1 - tm0) / i}")
print("")
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, True)

# Vierte Zeitmessung
tm0 = time.time_ns()
tm1 = 0
i = 0
while GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR):
i += 1
if tm0 != time.time_ns():
tm1 = time.time_ns()
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, False)
print("Vierte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)/i = {(tm1 - tm0) / i}")
print("")
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, True)

# Fünfte Zeitmessung
tm0 = time.time_ns()
tm00 = 0
tm1 = 0
i = 0
while GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR):
i += 1
tm00 = time.time_ns()
if i == 2100:
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, False)
tm1 = time.time_ns()
print("Fünfte Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm00: {tm00}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)/i = {(tm1 - tm0) / i}")
print("")
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, True)

# Sechste Zeitmessung
tm0 = time.time_ns()
tm00 = 0
tm1 = 0
i = 0
while GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR):
i += 1
tm00 = time.time_ns()
if i == 2200:
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, False)
tm1 = time.time_ns()
print("Sechste Zeitmessung")
print(f"i: {i}")
print(f"tm0: {tm0}")
print(f"tm00: {tm00}")
print(f"tm1: {tm1}")
print(f"tm1-tm0 = {tm1 - tm0}")
print(f"(tm1-tm0)/i = {(tm1 - tm0) / i}")
print("")
GLOBALS_20210819.FLAG_MWL(SHM_MKI_ATTR, True)


AUSGABE:

Erste Zeitmessung
i: 1
tm0: 1631153570843362800
tm1: 1631153570843362800
tm1-tm0 = 0
(tm1-tm0)/i = 0.0

Zweite Zeitmessung
i: 1256
tm0: 1631153570843362800
tm1: 1631153570844359400
tm1-tm0 = 996600
(tm1-tm0)/i = 793.4713375796179

Dritte Zeitmessung
i: 2149
tm0: 1631153570844359400
tm1: 1631153570845356400
tm1-tm0 = 997000
(tm1-tm0)/i = 463.936714751047

Vierte Zeitmessung
i: 2158
tm0: 1631153570845356400
tm1: 1631153570846353700
tm1-tm0 = 997300
(tm1-tm0)/i = 462.14087117701575

Fünfte Zeitmessung
i: 2100
tm0: 1631153570846353700
tm00: 1631153570846353700
tm1: 1631153570846353700
tm1-tm0 = 0
(tm1-tm0)/i = 0.0

Sechste Zeitmessung
i: 2200
tm0: 1631153570847351000
tm00: 1631153570848348300
tm1: 1631153570848348300
tm1-tm0 = 997300
(tm1-tm0)/i = 453.3181818181818


Schlussfolgerung:
Die Messungen zeigen, dass die While-Schleifendurchlauffrequenz bei 1,2 MHz liegt. Die Frequenz der Audioaufnahme beträgt 44,1 KHz.
Die Schleifendurchlauffrequenz der WHILE-Schleife mit SHM ist 28 mal höher als die Audioaufnahmefrequenz. 

Hochachtungsvoll
Artem Kraft

Kommentare

Beliebte Posts aus diesem Blog

[ TAG 38 ][29.05.2021] - Erfolgreich - Freelancer-Portale

[ TAG 747 ][07.04.2023] -Erfolgreich -BNKTRS -Google Code -Objekt und Methodenliste

[ TAG 52 ][12.06.2021] - Erfolgreich - IAP-20210601-20210609-2325