I've found Unity source code on GitHub [Unity-Technologies/UnityCsReference][1] and in particular this script: [Editor/Mono/PreferencesWindow/PreferencesWindow.cs][2]
Here is the line that responsible for Editor's Auto Refresh (which located in `Edit → Preferences → General → Auto Refresh checkbox`):
EditorPrefs.SetBool("kAutoRefresh", m_AutoRefresh);
By changing "m_AutoRefresh" variable you can switch auto compiling via code, if needed
[1]: https://github.com/Unity-Technologies/UnityCsReference
[2]: https://github.com/Unity-Technologies/UnityCsReference/blob/3cfc6c4729d5cacedf67a38df5de1bfffb5994a3/Editor/Mono/PreferencesWindow/PreferencesWindow.cs