Skip to content

Instantly share code, notes, and snippets.

@fedek6
Created June 7, 2019 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedek6/335480676d2b4efa6da5e962e7289e18 to your computer and use it in GitHub Desktop.
Save fedek6/335480676d2b4efa6da5e962e7289e18 to your computer and use it in GitHub Desktop.
szablon testowy WP
<?php
/*
* Template Name: Szablon testowy
*/
// taka prościzna do mierzenia czasu wykonania
function timeTook($start, $task = '') {
$execution_time = round( (microtime(true) - $start), 2);
return '<h4>Zadanie: <em>' . $task . '</em> zajęło: ' . $execution_time . ' sekund(y)</h4>';
}
// randomwy string do udawania imienia, nazwiska itp. itd.
function randomLetters($len = 5) {
return substr(str_shuffle("abcdefghijklmnopqrstuvwxyz"), 0, $len);
}
// mierzymy start wykonywania kodu
$start = microtime(true);
/**
* Od tej chwili testujemy sobie kod:
*/
// Przykład, wykonaj jakieś zadanie i sprawdź ile czasu to zajęło
for($i=0; $i<1000; $i++) {
echo randomLetters( rand(10,100) ) . '<br>';
}
// Po wykonaniu zadania robisz to:
echo timeTook($start, 'Wygenerowanie 1000 randomowych stringów');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment