[go: up one dir, main page]

File: Benchmark.py

package info (click to toggle)
uranium 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,876 kB
  • sloc: python: 22,349; sh: 111; makefile: 11
file content (24 lines) | stat: -rw-r--r-- 752 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Copyright (c) 2018 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.

import time
from UM.Logger import Logger
from UM.Application import Application

##  Static class used for benchmarking purposes. This class is only meant to be used as a static class.
class Benchmark:

    _start_time = None

    def __init__(self):
        raise Exception("This class is static only")

    @classmethod
    def start(cls, reference_text):
        Logger.log("d", "[BENCHMARK STARTS] %s", reference_text)
        Application.getInstance().callLater(cls._finished)
        cls._start_time = time.time()

    @classmethod
    def _finished(cls):
        Logger.log("d", "[BENCHMARK ENDS] Total time: %s", time.time() - cls._start_time)