Skip to content

Instantly share code, notes, and snippets.

View robertmarsal's full-sized avatar

Robert Marsal robertmarsal

  • RevEng.ai
  • London, UK
View GitHub Profile
@robertmarsal
robertmarsal / array_map_vs_foreach
Created November 22, 2011 12:27
Array_Map vs Foreach Benchmark
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
function microtimestamp() {
$timeofday = gettimeofday();
return $timeofday['sec'] + $timeofday['usec'] /
1000000;
}
@robertmarsal
robertmarsal / isPower2.java
Created February 11, 2011 22:50
recursive method to detect if a number is a power of 2
/**
* @author Robert Boloc
*/
public boolean isPower2(int v) {
if (v == 1) {
return true;
} else if (v % 2 != 0 || v == 0) {
return false;
} else {