diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
index 95dcc7415ddc..dbeaf3ab8f1a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -5,6 +5,7 @@ CHANGELOG
-----
* allowed multiple IP addresses in profiler matcher settings
+ * added stopwatch helper to time templates with the WebProfilerBundle
2.3.0
-----
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml
index 9aadc8156b82..2f9992aa4a7b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml
@@ -15,6 +15,7 @@
Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper
Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper
Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper
+ Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper
Symfony\Component\Form\Extension\Templating\TemplatingRendererEngine
Symfony\Component\Form\FormRenderer
Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables
@@ -101,6 +102,11 @@
+
+
+
+
+
%templating.helper.form.resources%
diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php
new file mode 100644
index 000000000000..47a9cf80ebcb
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php
@@ -0,0 +1,46 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
+
+use Symfony\Component\Stopwatch\Stopwatch;
+use Symfony\Component\Templating\Helper\Helper;
+
+/**
+ * StopwatchHelper provides methods time your PHP templates.
+ *
+ * @author Wouter J
+ */
+class StopwatchHelper extends Helper
+{
+ private $stopwatch;
+
+ public function __construct(Stopwatch $stopwatch = null)
+ {
+ $this->stopwatch = $stopwatch;
+ }
+
+ public function getName()
+ {
+ return 'stopwatch';
+ }
+
+ public function __call($method, $arguments = array())
+ {
+ if (null !== $this->stopwatch) {
+ if (method_exists($this->stopwatch, $method)) {
+ return call_user_func_array(array($this->stopwatch, $method), $arguments);
+ }
+
+ throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method));
+ }
+ }
+}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
new file mode 100644
index 000000000000..1a0ff5f548ce
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php
@@ -0,0 +1,39 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
+
+use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper;
+
+class StopwatchHelperTest extends \PHPUnit_Framework_TestCase
+{
+ public function testDevEnvironment()
+ {
+ $stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
+ $stopwatch->expects($this->once())
+ ->method('start')
+ ->with('foo');
+
+ $helper = new StopwatchHelper($stopwatch);
+ $helper->start('foo');
+ }
+
+ public function testProdEnvironment()
+ {
+ $helper = new StopwatchHelper(null);
+
+ try {
+ $helper->start('foo');
+ } catch (\BadMethodCallException $e) {
+ $this->fail('Assumed stopwatch is not called when not provided');
+ }
+ }
+}