Created
June 7, 2019 08:25
-
-
Save fedek6/335480676d2b4efa6da5e962e7289e18 to your computer and use it in GitHub Desktop.
szablon testowy WP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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