How long would a defragmentation take when you do it

Hi experts!
I am curious to know how long would a defragmentation take when you do it for the first time?
When I did it on my computer, it still did not finish after 12 hours.
And after I did it, I lost computer space. Did I do something wrong?
What should I do?
