What I did was to take the top-level function I didn't want to be inlined (say f) and simply add the following top-level code: val _ = if length (CommandLine.arguments ()) > 1000000 then (f some-arg; f some-arg; ...; f some-arg) else () which should take some code space, and add a single test to the time, but have no extra cost.