Best way to measure compile time

I’m doing various things right now to reduce our compile time (DLLs, Standard Assets, etc). However, I’ve been measuring our compile time by literally holding a timer and starting/stopping it. Terrible, I know. But I can’t figure out how to do this through an editor script.

First, I can’t seem to make Unity compile without some sort of problems. Unity will throw an error on the following code and will cause an Internal Compiler Error

AssetDatabase.StartAssetEditing();
AssetDatabase.ImportAsset(scriptToCompile, ImportAssetOptions.ForceSynchronousImport);
AssetDatabase.StopAssetEditing();

I then thought I might be able to record the end time with AssetPostprocessor.OnPostprocessAllAssets but then, I still don’t know how to start a compile.

Is there a plugin that already does all this? Does anybody know of a safe way to force re-compile?

Thanks.

In order to measure the compile time you could replace the Mono compiler with a command line tool that calls the real Mono compiler with the given arguments, measure the time, and return the result back to Unity.