From 8912e7bb59230e2b238ad2bf9fbf9f7a30fb9cf2 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Thu, 9 Dec 2010 17:42:09 +0100
Subject: [PATCH] Just a rough test version of a timing utility.
---
framework/Kolab_Format/bin/kolab-format | 3 +-
.../Kolab_Format/lib/Horde/Kolab/Format/Cli.php | 73 ++++++++++++++++++++++
2 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php
diff --git a/framework/Kolab_Format/bin/kolab-format b/framework/Kolab_Format/bin/kolab-format
index c0cee8475..5a5cf56ac 100755
--- a/framework/Kolab_Format/bin/kolab-format
+++ b/framework/Kolab_Format/bin/kolab-format
@@ -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
index 000000000..a27a26729
--- /dev/null
+++ b/framework/Kolab_Format/lib/Horde/Kolab/Format/Cli.php
@@ -0,0 +1,73 @@
+
+ * @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
+ * 'parser' - (array) Parser configuration parameters.
+ * 'class' - (string) The class name of the parser to use.
+ * 'output' - (Horde_Cli) The output handler.
+ *
+ */
+ 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
--
2.11.0