* @return $executionTime Current execution time in nice braces
*/
protected function getPrintableExecutionTime () {
- // Caculate the execution time
- $executionTime = microtime(true) - $this->getStartupTime();
-
- // Pack it in nice braces
- $executionTime = sprintf('[ %01.5f ] ', $executionTime);
+ // Calculate execution time and pack it in nice braces
+ $executionTime = sprintf('[ %01.5f ] ', (microtime(true) - $this->getStartupTime()));
// And return it
return $executionTime;
*/
const SEPARATOR_GAP_LENGTH = 0x03;
+ /**
+ * Minimum block length
+ */
+ private static $minimumBlockLength = 0;
+
/**
* Protected constructor
*
* @return $length Minimum length for one entry/block
*/
public function calculateMinimumBlockLength () {
- // Calulcate it
+ // Is it "cached"?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: CALLED!');
- $length = BaseBinaryFile::LENGTH_TYPE + strlen(chr(BaseBinaryFile::SEPARATOR_TYPE_POSITION)) + BaseBinaryFile::LENGTH_POSITION + strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES));
+ if (self::$minimumBlockLength == 0) {
+ // Calulcate it
+ self::$minimumBlockLength = (
+ // Type
+ BaseBinaryFile::LENGTH_TYPE + strlen(chr(BaseBinaryFile::SEPARATOR_TYPE_POSITION)) +
+ // Position
+ BaseBinaryFile::LENGTH_POSITION + strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES))
+ );
+ }
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-INDEX: length=%d - EXIT!', $length));
- return $length;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-INDEX: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength));
+ return self::$minimumBlockLength;
}
/**
// Exception codes
const EXCEPTION_BAD_MAGIC = 0xe100;
+ /**
+ * Minimum block length
+ */
+ private $minimumBlockLength = 0;
+
/**
* Protected constructor
*
* @return $length Minimum length for one entry/block
*/
public function calculateMinimumBlockLength () {
- // Calulcate it
+ // Is the value "cached"?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
- $length =
- // Length of entry group
- BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) +
- // Hash + value
- self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 +
- // Final separator
- strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES));
+ if (self::$minimumBlockLength == 0) {
+ // Calulcate it
+ self::$minimumBlockLength =
+ // Length of entry group
+ BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) +
+ // Hash + value
+ self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 +
+ // Final separator
+ strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES));
+ }
// Return it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: length=%d - EXIT!', $length));
- return $length;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength));
+ return self::$minimumBlockLength;
}
/**