Kirby 3 Plugin AutoID

This is the time Kirby needs to build the index. Done only once per page refresh.

1110 pages in index to call core kirby $page->index()

Pages with AutoID and their cached Collection with modified()

// setup a semi-unique id for this group
$collectionID = "page('autoid')->index()";

// get cached collection, returns null if modified
$collection = modified($collectionID);

// if does not exist yet or was modified
if(!$collection) {
  $collection = modified($collectionID, page('autoid')->index());
  echo '=> Collection Cache: created or refreshed because modified.'.PHP_EOL;
} else {
  echo '=> Collection Cache: read.'.PHP_EOL;

foreach($collection as $p) {
to check modified. Even if Kirbys Page Index is not created yet this time measurement stays the same. It depends only on AutoIDs cache.

=> Collection Cache: created or refreshed because modified.
to create/refresh/read collection from cache.
1110 pages in collection

If created or refreshed: check modified time + kirby index + write collection cache time
If cached: check modified time + read cache time = about 1/4 of index + almost 0

Usage autoid()

    [title] => Kirby 3 Plugin AutoID
    [text] => 953c64cc2db7346024d9f144390f2496
    [autoid] => abim0u8f
    [anystucture] => - 
  text: 9e279f7ef5929b8546142eaa4d0bccf7
  text: a75f7f44ae9f1f59e87ab5bfbeabfd1b
    [anystructure] => 
Kirby\Cms\Field Object
    [autoid] => abim0u8f
autoid()->filterBy('autoid', $page->autoid())->first();
    [pageid] => autoid
    [structure] => 
    [filename] => 
    [modified] => 1565958582
    [autoid] => abim0u8f
    [type] => page
$randomFileID = autoid()->filterBy('type', 'file')->shuffle()->first()['autoid'];
$randomFile = autoid($anyAutoID);
to find random file. duration does not depend on size of $page->index() only on count of items indexed.
$break = false;
foreach($page->index() as $pchi) {
  foreach($pchi->files() as $fi) {
    if($fi->id() == $randomFile->id()) {
      $break = true;
    if($break) break;
  if($break) break;
to find same file with foreach loops. duration increases with size of $page->index().
In addition to walking the for loops you would have to add the time to create the index (see top of page).

Usage tinyurl()