Skip to content

Commit

Permalink
Add a simple helper for benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
sniemela authored and Fabrice Luraine committed Jan 19, 2010
1 parent dee3257 commit d51c58a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 0 additions & 1 deletion TODO
Expand Up @@ -28,7 +28,6 @@ autoload_controller(['function']);
- new redirect_to (support for https)
- add header X-Limonade-PHP: (lim version name); (cosmetic ;-)
- use array_walk_recursive for unregister_globals
- add a simple helper for benchmarking (execution time / memory)
- simple form helper with XSS/CSRF protection
- remove examples/ and move it in an external depot
- public API documentation:
Expand Down
3 changes: 3 additions & 0 deletions examples/example02/index.php
Expand Up @@ -130,6 +130,9 @@ function html_my_layout($vars){ extract($vars);?>
</p>
</body>
</html>
<!--
<?php print_r(benchmark()); ?>
-->
<?}


Expand Down
19 changes: 19 additions & 0 deletions lib/limonade.php
Expand Up @@ -1698,6 +1698,25 @@ function end_content_for()
content_for();
}

/**
* Shows current memory and execution time of the application.
*
* @access public
* @return array
*/
function benchmark()
{
$current_mem_usage = memory_get_usage();
$execution_time = microtime() - LIM_START_MICROTIME;

return array(
'current_memory' => $current_mem_usage,
'start_memory' => LIM_START_MEMORY,
'average_memory' => (LIM_START_MEMORY + $current_mem_usage) / 2,
'execution_time' => $execution_time
);
}




Expand Down

0 comments on commit d51c58a

Please sign in to comment.