# Time elapsed for aborted computation?

I have a computation which is taking very long

AbsoluteTiming[sr = ShellRegion@region];


Instead of getting \$Aborted, is there a system method to get a time estimate of how long it was running before being aborted?

• Do you mean you leave it running, press Alt+., and then you want to see how long there in between the abort keystokes and when the evaluation queue is free again?
– ktm
Aug 21 '16 at 1:59
• I think so yes, or until it freezes and I kill it
– M.R.
Aug 21 '16 at 2:04
• Out of curiosity, what is region? Sep 12 '16 at 19:14

Maybe the following construct suits your need, take for example

Module[{tic},
tic = SessionTime[];
CheckAbort[
Do[Print[n]; Pause[1], {n, 10}] (* here goes your expression *),
SessionTime[] - tic
]


or wrapped in a convenient function

SetAttributes[try, HoldFirst]
try[expr_] := Module[{tic},
tic = SessionTime[];
CheckAbort[expr, SessionTime[] - tic]
]


that can be called with some expression you wish to evaluate

try[Do[Pause[1]; Print[n], {n, 10}]]


Simply wrapping your computation in CheckAbort as suggested by @Sascha seems to be sufficient to achieve most of what you want. E.g.

AbsoluteTiming[CheckAbort[Pause[20], Null]]