When iTunes runs "Determining Gapless Playback" repeatedly and so often as to even interrupt your computer's ability to go to sleep, it may be because there are some mp3 files with errors present.
The errors may be so subtle that you've never heard any problems, or there may be major errors that would sound like skipping.
As an Apple user you probably do not have many mp3 files, since mp4s are more standard. But at some point you saved some mp3s, and they may be responsible.
So open finder, and find all of your mp3s.
Drag them into any free application that evaluates and repairs mp3s, such as "MP3 Scan + Repair" by Christian Zuckschwerdt. I don't want to seem to be promoting his above any other similar apps, but that is the one I've used myself.
First look at the mp3s that it shows have Errors - unfixable errors, like the file is completely unplayable, or has blatant skips that you would have noticed if you'd ever played the track. You may find two or three of those. I found one mp3 that was 0KB in size. I found one that I'd helpfully labelled "this track skips!" but had not deleted because I had no idea it would wreak havoc with iTunes' ability to determine gapless playback. Delete them. (Or, if they can be played you may want to try converting them, but delete the original).
Now look at the mp3s that it shows have Warnings. These tend to be extremely minor problems that you'd never notice when listening, typically involving some garbage characters in the last frame of the mp3 or some slightly incorrect header information. I had a few hundred of those. All of which were easily fixed by clicking the Fix button, which sliced off the last frame or rewrote the header.
And that solved it for me. Next time iTunes did its "Determining Gapless Playback" routine it was satisfied with the results. My computer once again could go to sleep.
That was my experience; I don't know if it will solve your problem but if it does please say so. Thanks.