HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
ftest_profiler.py
Go to the documentation of this file.
1 import os
2 
3 #import ppath
4 #from ppath import sys
5 
6 import logging.config
7 from time import sleep
8 
9 import app.Profiler as Profiler
10 
11 class SomeClass:
12  """A simple class for simulate work"""
13  def __init__(self):
14  print "SomeClass was created"
15 
16  def fewSleepCalls(self):
17  self.bigSleep()
18  self.smallSleep()
19 
20  def bigSleep(self):
21  self.__sleep(3)
22 
23  def smallSleep(self):
24  self.__sleep(1)
25 
26  def __sleep(self, seconds):
27  print "SomeClass sleep"
28  sleep(seconds)
29  print "SomeClass wake up"
30 
31 
32 if __name__ == "__main__":
33 
34  # Save current working directory.
35  retdir = os.getcwd()
36  #For test necessary
37  os.chdir('../')
38 
39  pr = Profiler.Profiler()
40 
41  print('isStarted: ' + str(pr.isStarted))
42  print('status: ' + str(pr.status))
43  print('loggerConfigName: ' + pr.loggerConfigName)
44  print('traceback: ' + str(pr.traceback))
45 
46  pr.readConfig(pr.loggerConfigName)
47 
48  pr.start()
49  pr.start()
50 
51  print('isStarted: ' + str(pr.isStarted))
52 
53  x = SomeClass()
54  x.fewSleepCalls()
55 
56  pr.stop()
57 
58  print('isStarted: ' + str(pr.isStarted))
59 
60  pr.stop()
61  # Restore working directory.
62  os.chdir(retdir)
63