Just a rough test version of a timing utility.
authorGunnar Wrobel <p@rdus.de>
Thu, 9 Dec 2010 16:42:09 +0000 (17:42 +0100)
committerGunnar Wrobel <p@rdus.de>
Mon, 13 Dec 2010 10:17:17 +0000 (11:17 +0100)
framework/Kolab_Format/bin/kolab-format
framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php [new file with mode: 0644]

index c0cee84..5a5cf56 100755 (executable)
@@ -4,4 +4,5 @@ if (strpos('@php_dir@', '@php_dir') === 0) {
     set_include_path(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path());
 }
 
-
+require_once 'Horde/Autoloader/Default.php';
+Horde_Kolab_Format_Cli::main();
diff --git a/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php b/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php
new file mode 100644 (file)
index 0000000..a27a267
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Command line tools for Kolab format.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Format
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Format
+ */
+
+/**
+ * Command line tools for Kolab format.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did not
+ * receive this file, see
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Format
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Format
+ */
+class Horde_Kolab_Format_Cli
+{
+    /**
+     * The main entry point for the application.
+     *
+     * @param array $parameters A list of named configuration parameters.
+     * <pre>
+     * 'parser'   - (array)     Parser configuration parameters.
+     *   'class'  - (string)    The class name of the parser to use.
+     * 'output'   - (Horde_Cli) The output handler.
+     * </pre>
+     */
+    static public function main(array $parameters = array())
+    {
+        $parser = self::_prepareParser($parameters);
+        if (empty($parameters['output'])) {
+            $cli = Horde_Cli::init();
+        } else {
+            $cli = $parameters['output'];
+        }
+        list($options, $arguments) = $parser->parseArgs();
+        $factory = new Horde_Kolab_Format_Factory();
+        $timed = $factory->createTimed('xml', 'task');
+        for ($i = 0; $i < 1000; $i++) {
+            $timed->load(
+                file_get_contents($arguments[0])
+            );
+        }
+        $cli->message($timed->timeSpent());
+    }
+
+    static private function _prepareParser(array $parameters = array())
+    {
+        if (empty($parameters['parser']['class'])) {
+            $parser_class = 'Horde_Argv_Parser';
+        } else {
+            $parser_class = $parameters['parser']['class'];
+        }
+        return new $parser_class(
+            array(
+                'usage' => '%prog ' . _("[options] PACKAGE_PATH")
+            )
+        );
+    }
+}
\ No newline at end of file