Daniel Johnson

28 Followers
68 Following
67 Posts

#Drupal geek and cat lover. Currently employed by WebFirst.

Other interests:
- Music engraving using #Lilypond
- Choral music arrangements and conducting
- Trying to become a less-lame #bassist
- Typography
- Gardening, then forgetting about the garden when the weeds come
- Hiking
- #Cocktails and mixology

Fun fact: I designed four of the fonts available on Google WebFonts. One of them was used almost exclusively for a couple of years by Facebook meme-makers who can't spell.

GitHubhttps://github.com/ossobuffo
Drupal.orghttps://www.drupal.org/u/daniel_j
@timwolla You're right. I upped it to 1M iterations, and it evened out, with directly casting coming out ahead by less than 0.01% on average.

@timwolla Weird. This was in a non-namespaced script:
```
$test_me = 1;

print "Cast as boolean:\n";
$time = hrtime(true);
for ($i = 0; $i < 1000; $i++) {
$tested = (bool) $test_me;
}
$cast_elapsed = hrtime(true) - $time;
print "1000 casts in $cast_elapsed nanoseconds.\n";

print "Call boolval():\n";
$time = hrtime(true);
for ($i = 0; $i < 1000; $i++) {
$tested = boolval($test_me);
}
$func_elapsed = hrtime(true) - $time;
print "1000 invocations in $func_elapsed nanoseconds.\n";
```

EDIT: Disregard this, invalid test. Iterating 1M times instead of 1k irons out the wrinkles.

Ever wondered whether it's faster to directly cast a variable versus invoke a casting function in PHP?

I wondered, so I wrote a script that calls (bool) $int 1000 times, then invokes boolval($int) 1000 times. It turns out that boolval() is between 15% and 250% faster than an explicit cast.

I'll bet the same is true for intval(), floatval(), and strval().

#PHP

@nuintari @da_667

And all that is now
And all that is gone
And all that's to come
And everything under the sun is in tune
But the sun is eclipsed by the moon

Sigh. Bitten again by MacOS's "sometimes case-sensitive, sometimes not" inconsistencies.
@syntaxseed One of many reasons so many of us cheered wildly when Drupal decided to adopt Twig as its templating engine.
@volkswagenchick Put it in a roast beef sandwich with horseradish sauce.

My employer is hiring for the position of Sr. #Drupal Developer. We operate in the Federal space, so this is a USA-only position. For more details, see here: https://www.webfirst.com/careers/sr-full-stack-drupal-developer

#jobs #FediHire

@drupalthoughts Don't forget to diff each contrib module against a vanilla copy of the same version. It sounds like the site was built by incompetent boobs, and they probably hacked contrib (and maybe even core).
@drupalthoughts I manually downloaded composer 1 and saved it to /usr/local/bin/composer1. Then you just have to remember to invoke composer1 instead of composer.