Amazon clearly states on their EC2 Page and their Instance Types Page what the stats of each machine is.
For example the free tier you likely tried out and was not impressed with the performance with is a "micro instance"
Micro Instance 613 MiB of memory, up to 2 ECUs (for short periodic bursts), EBS storage only, 32-bit or 64-bit platform
Now there is one translation we need to do ECUs to actual processing power
EC2 Compute Unit (ECU) – One EC2 Compute Unit (ECU) provides the equivalent CPU capacity of a 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor.
So the machine you tested it on was a computer with 2.0-2.4 GHz (but only for short periodic bursts) that only had 613 MiB of RAM.
The ram is likely the thing that killed your performance. Your machine had triple the ram the EC2 machine did and had 8 cores (and likely running faster than the bursting speed of the EC2 instance) compared to the EC2 machines 1 core.
Now compare this to the "High-Memory Quadruple Extra Large Instance"
High-Memory Quadruple Extra Large Instance 68.4 GiB of memory, 26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each), 1690 GB of local instance storage, 64-bit platform
So now we have a machine that has 68.4 gigs of RAM compared to your 8, and has 8 cores (same as you) and running at 3.25 to 3.9 Ghz.
This machine will likely beat your machine doing the same task.
Now, why use EC2? What if you wanted to run 20 copies of your test at the same time, at home you would need to buy 19 more machines (lets say $1000 per machine), so you would need to spend $19000 now and when you are done you have servers you don't need any more not doing anything at all.
By using EC2, you could rent 20 servers and only pay for 1 hour of usage. At $1.00 per hour rate for the High-Memory Quadruple Extra Large Instance it would only cost you $20.