One of the best ways to eliminate fragmentation is to do a Backup and Restore. But the problem at hand is not likely to be fragmentation. Mac OS X de-fragments large files automatically when they are opened. If you are seeing real slowness, that is sometimes attributable to Bad Blocks.
Every block on disk is written in a semi-redundant form with additional bits added for correcting for small bursts of errors that sometimes happen with magnetic media. The kinds of codes used are called Fire codes. But sometimes even with Error Correction, the data cannot be read without error.
So the disk controller does a retry. 10 times. Then the error is reported to the Disk Driver. It does a retry. 10 times. each of those is retried. 10 times. Then the error is reported to a higher level in Mac OS X. It does a retry. 10 times. We could be up to a thousand retries now. If the data ever come out correct, we move on. If not, you could be here a while trying over and over to get correctable data.
--------
A drive controller has a "private stash" of spare blocks, scattered across the surface of the disk so that some will always be not-too-far away. When new data are supplied, a troublesome block can be re-written and today's controllers can check for integrity immediately after the re-write. If the data are recorded properly, nothing changes. If the block is still not working after being re-written, it is permanently removed from play and a spare block is substituted. The controller notes the substitution on its internal Bad Blocks list. The blocks available to the Application do not change -- it is as if nothing happened.
The conventional way of doing this has been a pass of writing all zeroes to the entire drive. If there are not too many spares used, the drive passes. If the drive runs out of spares, or too many are used in one pass, "Initialization Failed" message is displayed.
The problem is, drives have gotten so big, this takes all afternoon, and may result in the drive being declared dead after all that time. So what often happens if a drive is suspected of Bad Blocks, is a new drive is installed, and the old drive will be returned to you for YOU to take all afternoon and into the night fiddling with it to see if it will perk up, or be declared a doorstop.