Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
New Feature: WIP - Initial Support for HHVM
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepone committed Aug 2, 2014
1 parent 4830809 commit 6b5d891
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 6 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
// Clean up the configuration vars
unset($application, $modules, $system, $themes);

// HHVM's reported memory usage from memory_get_peak_usage()
// is not useful when passing false, but we continue passing
// false for consistency of historical data in zend.
$realMemoryUsage = defined('HHVM_VERSION');

/**
* Define the start time of the application, used for profiling.
*/
Expand All @@ -114,7 +119,7 @@
/**
* Define the memory usage at the start of the application, used for profiling.
*/
defined('GLEEZ_START_MEMORY') OR define('GLEEZ_START_MEMORY', memory_get_usage());
defined('GLEEZ_START_MEMORY') OR define('GLEEZ_START_MEMORY', memory_get_usage($realMemoryUsage));

// Bootstrap the application
require APPPATH.'bootstrap'.EXT;
Expand Down
12 changes: 10 additions & 2 deletions modules/gleez/classes/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,15 @@ public static function is_datatables(Request $request = NULL)
return (bool) $request->query('draw');
}

/**
* Check if we are running under HHVM
*
* @return Bool
*/
public static function isHHVM() {
return defined('HHVM_VERSION');
}

/**
* Gets POST max size in bytes
*
Expand Down Expand Up @@ -1790,5 +1799,4 @@ public function is_delete()
{
return (self::DELETE === $this->_method);
}
}

}
7 changes: 6 additions & 1 deletion modules/gleez/classes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,14 @@ protected function _set_profiler_stats()
}
}

// HHVM's reported memory usage from memory_get_peak_usage()
// is not useful when passing false, but we continue passing
// false for consistency of historical data in zend.
$realMemoryUsage = Request::isHHVM();

// Get the total memory and execution time
$total = array(
'{memory_usage}' => number_format((memory_get_peak_usage() - GLEEZ_START_MEMORY) / 1024 / 1024, 2) . ' ' . __('MB'),
'{memory_usage}' => number_format((memory_get_peak_usage($realMemoryUsage) - GLEEZ_START_MEMORY) / 1024 / 1024, 2) . ' ' . __('MB'),
'{gleez_version}' => Gleez::VERSION,
'{execution_time}' => number_format(microtime(TRUE) - GLEEZ_START_TIME, 3) . ' ' . __('seconds'),
'{included_files}' => count(get_included_files()),
Expand Down

1 comment on commit 6b5d891

@sergeyklay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine! good work :) 👍

Please sign in to comment.