Created
April 29, 2015 01:43
-
-
Save tjluoma/293aae9628c65d41d01a to your computer and use it in GitHub Desktop.
This is a shell script I wrote to test how fast StretchLink 1.0 (http://brettterpstra.com/2015/04/28/stretchlink-1-dot-0/) works, as referenced at http://www.macstories.net/linked/stretchlink-unshortens-and-cleans-urls-from-your-menu-bar/
This file contains 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
#!/bin/zsh -f | |
# this is necessary for ZSH to be able to use $EPOCHSECONDS | |
zmodload zsh/datetime | |
# this gives a date/time stamp without requiring an external call to the `date` | |
# program | |
function timestamp { strftime "%Y-%m-%d--%H.%M.%S" "$EPOCHSECONDS" } | |
# This was the tricky part: | |
# I dragged this URL from Tweetbot to the shell script, | |
# which added it to the document _without_ putting it on the pasteboard | |
# Otherwise, of course, the test wouldn't be valid because | |
# StretchLink would start working on it immediately. | |
# | |
# The `echo` line will send it to the pasteboard, which is what should | |
# trigger StretchLink | |
echo "http://bit.ly/1JqLxBW" | pbcopy | |
# immediately after that (as fast as computationally possible) | |
# the script will go into a loop, | |
# showing me the contents of the pasteboard | |
# followed by a timestamp down to the second | |
# (I broke the loop manually using control+c) | |
while | |
do | |
echo "\n`pbpaste`" | |
timestamp | |
done | |
exit 0 | |
# EOF |
Note that StretchLink caches URLs that it has expanded until quit, so if you run this test more than once you will need to either quit the app or change the URL. Be sure it doesn't get expanded when you're adding it to the script!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result:
These lines repeated 18 times:
and then this appeared:
That means that the URL was expanded in less than 1 second. Tenths of a second.
There's no meaningful way that this could be faster.