That's rarely as effective as people think:
tmpfs
$ dd if=/dev/random of=/tmp/deleteme bs=1m count=4096 ;rm /tmp/deleteme
4096+0 records in
4096+0 records out
4294967296 bytes transferred in 9.549101 secs (449777126 bytes/sec)
HDD
$ dd if=/dev/random of=~/deleteme bs=1m count=4096 ;rm ~/deleteme
4096+0 records in
4096+0 records out
4294967296 bytes transferred in 9.419404 secs (455970160 bytes/sec)
In both cases dd is going to write to the kernel's filesystem buffer cache in the first instance, which is memory. If the kernel has a lot of free memory available, it is able to use that for filesystem write buffer cache, so you are effectively writing to memory, and using a tmpfs target provides no advantage over the HDD.
What happens if you pass an additional 'oflag=direct' argument to dd, to (hopefully) bypass the kernel filesystem buffer?
And if you specify synchronous writes?
From the dd manpage:-
oflag=value[,value ...]
Where value is one of the symbols from the following list.
fsync Set the O_FSYNC flag on the output file to make writes
synchronous.
sync Set the O_SYNC flag on the output file to make writes
synchronous. This is synonymous with the fsync value.
direct Set the O_DIRECT flag on the output file to make writes
bypass any local caching.
You can also try adding 'conv=fsync' to the dd command to force dd to call fsync(2) to flush the buffer cache.
So for example try
dd if=/dev/random of=~/deleteme bs=1m count=4096 oflag=sync,direct conv=fsync
and then see if there is any difference in execution time between writing to the tmpfs and HDD targets.
We also need to consider that your HDD itself probably has an onboard hardware RAM cache, which may be quite large, depending on the drive model. On linux a drive's write back cache can be disabled using 'hdparm -W 0'. Whereas it appears freebsd has sysctl interfaces to disable drive write caches
https://forums.freebsd.org/threads/is-there-a-simple-way-to-disable-write-cache.56367/
So you actually have to work quite hard to bypass all the various type of caching in the system to get to the point where you see a difference in write speed due to the underlying mass storage device itself. Of course how soon you reach the point at which you do observe a difference will depend on how much free memory the kernel has available to allocate to the filesystem buffer, and the size of the data being written. The speed difference is more apparent when you write directly to a device, as when dd'ing directly to a usb flash drive; the filesystem cache is not used in that case, since you are not writing to a filesystem..