clipboard is a command-line tool for getting and setting the clipboard. Simple sample uses:
pbpaste is the clipboard-interface program that comes with Mac OS X 10.1, and pbcopy and pbpaste are the clipboard-interface programs that come with Mac OS X 10.3 and later (I don't know about 10.0 and 10.2). I did some comparisons between clipboard 2.0 and pbcopy. Here's the output.
| clipboard 2.0 | pbcopy from 10.3.3 |
|---|---|
| 7.506 | 33.056 |
The times are in seconds.
% cd ~/Projects/clipboard/clipboard-20
% buildit --fast=G4
gcc -std=c99 clipboard.c -fast -mcpu=G4 -mtune=G4 -s -no-cpp-precomp -framework Carbon -o clipboard
% clipboard --version
clipboard 2.0
Compiled with:
Escalating allocation
Memory-mapped input
Argument support
Clipboard concatenation
% du -h ~/Documents/bigger-headers.txt
100M /Users/boredzo/Documents/bigger-headers.txt
% du -b ~/Documents/bigger-headers.txt
104857600 /Users/boredzo/Documents/bigger-headers.txt
% #with iTunes 4.2 (v72) running and playing
% time clipboard -c ~/Documents/bigger-headers.txt
clipboard -c ~/Documents/bigger-headers.txt 1.76s user 3.47s system 40% cpu 13.005 total
% time clipboard -c ~/Documents/bigger-headers.txt
clipboard -c ~/Documents/bigger-headers.txt 1.69s user 3.66s system 35% cpu 14.996 total
% time clipboard -c ~/Documents/bigger-headers.txt
clipboard -c ~/Documents/bigger-headers.txt 1.96s user 3.64s system 43% cpu 12.797 total
% time pbcopy < ~/Documents/bigger-headers.txt
pbcopy < ~/Documents/bigger-headers.txt 8.29s user 3.55s system 31% cpu 37.668 total
% time pbcopy < ~/Documents/bigger-headers.txt
pbcopy < ~/Documents/bigger-headers.txt 8.13s user 3.68s system 17% cpu 1:06.68 total
% time pbcopy < ~/Documents/bigger-headers.txt
pbcopy < ~/Documents/bigger-headers.txt 8.35s user 3.95s system 17% cpu 1:10.28 total
% #without iTunes running
% time clipboard -c ~/Documents/bigger-headers.txt
clipboard -c ~/Documents/bigger-headers.txt 1.79s user 4.35s system 65% cpu 9.309 total
% time clipboard -c ~/Documents/bigger-headers.txt
clipboard -c ~/Documents/bigger-headers.txt 1.62s user 4.02s system 85% cpu 6.609 total
% time clipboard -c ~/Documents/bigger-headers.txt
clipboard -c ~/Documents/bigger-headers.txt 1.84s user 3.68s system 83% cpu 6.602 total
% time pbcopy < ~/Documents/bigger-headers.txt
pbcopy < ~/Documents/bigger-headers.txt 8.49s user 3.59s system 77% cpu 15.515 total
% time pbcopy < ~/Documents/bigger-headers.txt
pbcopy < ~/Documents/bigger-headers.txt 8.02s user 3.41s system 27% cpu 41.447 total
% time pbcopy < ~/Documents/bigger-headers.txt
pbcopy < ~/Documents/bigger-headers.txt 8.13s user 3.42s system 27% cpu 42.207 total
% #computing the averages
% dc
3k #precision: three decimal places
#without iTunes running
9.309 6.609+ 6.602+ 3/p
7.506 #clipboard
15.515 41.447+ 42.207+ 3/p
33.056 #pbcopy
#with iTunes running
13.005 14.996+ 12.797+ 3/p
13.599 #clipboard
37.668 66.68+ 70.28+ 3/p
58.209 #pbcopy
|
I did a similar comparison against toclip, which is clipboard's only third-party competitor. Unlike clipboard and pbpaste, toclip is $7 shareware. Surprisingly, it does come with source code, so I was able to analyse the two programs and see how they worked differently.
% time toclip < ~/Documents/big-headers.txt ^C toclip < ~/Documents/big-headers.txt 4612.66s user 27.03s system 77% cpu 1:39:49.12 total
The time shown is the amount of time that had elapsed when the program was interrupted by pressing ctrl-C: one hour, 39 minutes, and 49.12 seconds. this test was run under Mac OS X 10.1.5 running zsh 4.1.1 and toclip 1.0.
Analysis of clipboard 2.0 vs toclip 1.0 (pbpaste isn't open-source):
| clipboard 2.0 | toclip 1.0 |
|---|---|
|
|
| 2006-09-01 http://boredzo.org./clipboard/ |
|