Adding policy manager and a1 sdnc vth
[it/otf.git] / a1-policy-manager-vth / app / helpers / time_helper.py
diff --git a/a1-policy-manager-vth/app/helpers/time_helper.py b/a1-policy-manager-vth/app/helpers/time_helper.py
new file mode 100644 (file)
index 0000000..b882d0b
--- /dev/null
@@ -0,0 +1,24 @@
+"""\r
+    Module Info:\r
+"""\r
+import datetime\r
+\r
+def unix_time_millis(d_time):\r
+    """\r
+    Args:\r
+    Returns:\r
+    Examples:\r
+    """\r
+    epoch = datetime.datetime.utcfromtimestamp(0)\r
+    return (d_time - epoch).total_seconds() * 1000.0\r
+\r
+def timed_function(func):\r
+    """\r
+    Args:\r
+    Returns:\r
+    Examples:\r
+    """\r
+    start_time = unix_time_millis(datetime.datetime.now())\r
+    func()\r
+    end_time = unix_time_millis(datetime.datetime.now())\r
+    return end_time - start_time\r