Skip to content
Snippets Groups Projects

Version 0.1.0 (setup)

Merged Adrien Crovato requested to merge adri into master
1 file
+ 0
53
Compare changes
  • Side-by-side
  • Inline
+ 0
53
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2020 University of Liège
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Test the timers
# Adrien Crovato
import fpm
import time
from fwk.testing import *
from fwk.coloring import ccolors
def main():
tms = fpm.Timers()
tms['1'].start()
time.sleep(0.3)
tms['1'].stop()
tms['2'].start()
tic = time.perf_counter()
dummy()
toc = time.perf_counter()
tms['2'].stop()
print(ccolors.ANSI_BLUE + 'PyTiming...' + ccolors.ANSI_RESET)
print(tms)
print(ccolors.ANSI_BLUE + 'PyTesting...' + ccolors.ANSI_RESET)
tests = CTests()
tests.add(CTest('1w', tms['1'].getWall(), 0.3, 2e-2))
tests.add(CTest('1u', tms['1'].getCpu(), 0.0, 1e-2))
tests.add(CTest('2w', tms['2'].getWall(), toc - tic, 2e-2))
tests.add(CTest('2u', tms['2'].getCpu(), toc - tic, 2e-2))
tests.run()
def dummy():
for i in range(0, int(1e7)):
a = 1+1
if __name__ == '__main__':
main()
Loading