Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 sleepy-mustache
Copyright (c) 2020 sleepyMUSTACHE

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Performance

* Date: April 16, 2014
* Date: March 2, 2020
* Author: Jaime A. Rodriguez <hi.i.am.jaime@gmail.com>
* Version: 1.0
* Version: 2.0
* License: http://opensource.org/licenses/MIT

Adds a comment to the end of the source code telling the amount of memory used and total run time.

Adds a comment to the end of the source code telling the amount of memory used and
total run time.

## Usage

Expand Down
73 changes: 73 additions & 0 deletions Timer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* The Timer class used in the Performance Module to display the execution time and
* memory usage
*
* PHP version 7.0.0
*
* @category Performance
* @package Module/Performance
* @author Jaime Rodriguez <hi.i.am.jaime@gmail.com>
* @license https://opensource.org/licenses/MIT MIT
* @version GIT: 1.0.0
* @link http://sleepymustache.com
*/

namespace Module\Performance;

use Sleepy\Core\Hook;
use Sleepy\Core\Module;

/**
* Timer Module
*
* @category Performance
* @package Module/Performance
* @author Jaime Rodriguez <hi.i.am.jaime@gmail.com>
* @license https://opensource.org/licenses/MIT MIT
* @link http://sleepymustache.com
*/
class Timer extends Module
{
/**
* Define the hook points
*/
public $hooks = [
'sleepy_preprocess' => 'startTimer',
'sleepy_postprocess' => 'stopTimer'
];

public function __construct() {
$this->environments['dev'] = true;
$this->environments['stage'] = false;
$this->environments['live'] = false;

// The parent contructor must be called
parent::__construct();
}

/**
* Starts the timer when the framework loads.
*
* @return void
*/
public function startTimer()
{
$this->startTime = microtime(true);
}

/**
* When everything is done, append the time and memory usage to the file
*
* @return void
*/
public function stopTimer()
{
$this->stopTimer = microtime(true) - $this->startTime;
echo "\n<!-- Generated in $this->stopTimer seconds using " .
(memory_get_peak_usage() / 1024) .
" kb memory, by sleepyMUSTACHE -->";
}
}

Hook::register(new Timer());
34 changes: 0 additions & 34 deletions performance.php

This file was deleted.