aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-02-07 23:53:58 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-02-07 23:53:58 +0000
commitdd0d9dfcca6d9c0d7babba263c7d476c97f1f7ba (patch)
tree875700ece8cdd8fcc4a1010c60be3a56bda48ca3 /lib/python
parent8320dc7c52e253425fe588cda50da50ac6590060 (diff)
downloadenigma2-dd0d9dfcca6d9c0d7babba263c7d476c97f1f7ba.tar.gz
enigma2-dd0d9dfcca6d9c0d7babba263c7d476c97f1f7ba.zip
add 'profile': log individual starting times, and use them on next run to estimate progress. write progress to lcd.
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Tools/Makefile.am2
-rw-r--r--lib/python/Tools/Profile.py42
2 files changed, 43 insertions, 1 deletions
diff --git a/lib/python/Tools/Makefile.am b/lib/python/Tools/Makefile.am
index 0bc82009..0050ee34 100644
--- a/lib/python/Tools/Makefile.am
+++ b/lib/python/Tools/Makefile.am
@@ -4,4 +4,4 @@ install_PYTHON = \
FuzzyDate.py XMLTools.py Directories.py NumericalTextInput.py \
KeyBindings.py BoundFunction.py ISO639.py Notifications.py __init__.py \
RedirectOutput.py DreamboxHardware.py Import.py Event.py CList.py \
- RedirectTime.py LoadPixmap.py
+ RedirectTime.py LoadPixmap.py Profile.py
diff --git a/lib/python/Tools/Profile.py b/lib/python/Tools/Profile.py
new file mode 100644
index 00000000..1c44bc84
--- /dev/null
+++ b/lib/python/Tools/Profile.py
@@ -0,0 +1,42 @@
+import time
+from Directories import resolveFilename, SCOPE_SYSETC
+
+PERCENTAGE_START = 50
+PERCENTAGE_END = 100
+
+profile_start = time.time()
+
+profile_data = {}
+total_time = 1
+
+try:
+ profile_old = open(resolveFilename(SCOPE_SYSETC, "profile"), "r").readlines()
+
+ t = None
+ for line in profile_old:
+ (t, id) = line[:-1].split('\t')
+ t = float(t)
+ total_time = t
+ profile_data[id] = t
+except:
+ print "no profile data available"
+
+profile_file = open(resolveFilename(SCOPE_SYSETC, "profile"), "w")
+
+def profile(id):
+ now = time.time() - profile_start
+ if profile_file:
+ profile_file.write("%.2f\t%s\n" % (now, id))
+ if id in profile_data:
+ t = profile_data[id]
+ perc = t * (PERCENTAGE_END - PERCENTAGE_START) / total_time + PERCENTAGE_START
+ try:
+ open("/proc/progress", "w").write("%d \n" % perc)
+ except IOError:
+ pass
+
+def profile_final():
+ global profile_file
+ if profile_file is not None:
+ profile_file.close()
+ profile_file = None