-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add perf_counter widget for accuracy check
- Loading branch information
Showing
4 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import sys | ||
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel | ||
from PySide6.QtCore import QTimer | ||
from PySide6.QtGui import QFont | ||
import time | ||
|
||
class PerfCounterWidget(QWidget): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
# Set up the layout | ||
self.layout = QVBoxLayout() | ||
self.perfLabel = QLabel(self) | ||
|
||
font = QFont() | ||
font.setPointSize(100) | ||
self.perfLabel.setFont(font) | ||
|
||
self.layout.addWidget(self.perfLabel) | ||
self.setLayout(self.layout) | ||
|
||
|
||
|
||
# Timer to update the label every 100 milliseconds for smoother updates | ||
self.timer = QTimer(self) | ||
self.timer.timeout.connect(self.updateLabel) | ||
self.timer.start(10) # Update interval in milliseconds | ||
|
||
|
||
def updateLabel(self): | ||
# Calculate elapsed time since the start of the application | ||
elapsedTime = time.perf_counter() | ||
# Update the label with the current perf_counter value | ||
self.perfLabel.setText(f"{elapsedTime:.4f}") | ||
|
||
|
||
|
||
def main(): | ||
app = QApplication(sys.argv) | ||
widget = PerfCounterWidget() | ||
widget.show() | ||
sys.exit(app.exec_()) | ||
|
||
if __name__ == "__main__": | ||
|
||
main() | ||
|