Big patch merging crawling+indexing into one command, new json document structure
[phinde.git] / src / phinde / Helper.php
index 43345ba22899c890966c5a659bda068b0daebbe6..00215fee0ca72b0cdb5d1fee5f175d8b46ad0202 100644 (file)
@@ -31,6 +31,12 @@ class Helper
         return 'http://' . $url;
     }
 
+    public static function removeAnchor($url)
+    {
+        $parts = explode('#', $url, 2);
+        return $parts[0];
+    }
+
     public static function sanitizeTitle($str)
     {
         return trim(
@@ -59,5 +65,17 @@ class Helper
         return $prot . '://' . $_SERVER['HTTP_HOST'] . $path;
     }
 
+    static $timer = [];
+
+    public static function start($timer = 'timer')
+    {
+        static::$timer[$timer] = microtime(true);
+    }
+
+    public static function stop($timer = 'timer')
+    {
+        $diff = microtime(true) - static::$timer[$timer];
+        echo '+timer: ' . number_format($diff, 3) . 'ms ' . $timer . "\n";
+    }
 }
 ?>