Recently I was reading *Mathematica® programming: an advanced introduction*, and found a function called [`myTiming`](http://www.mathprogramming-intro.org/book/node297.html). It differs from build-in `Timing` function, as the author noted, in the way that it can measure small intervals of time.

However, perhaps due to the change of Mathematica syntax in newer versions, `myTiming` gets stuck after generating a number of warnings in version 11. The warning messages, together with my code, are attached below.

I am just a beginner for Mathematica, can anyone please give some suggestions on improvement?

```
Clear[myTiming];
myTiming[x_] := 
  Module[
    {z = 0, y = 0, timelim = 0.1, p, q, 
     iterlist = (Power[10, #] & /@ Range[0, 10]),
     nm = If[ToExpression[StringTake[$Version, 1]] < 6, 2, 1]},
    Catch[
      If[(z = Nest[First, Timing[(y++; Do [x, {#}]);], nm]) > timelim, 
        Throw[{z, y}]] & /@ iterlist] /. {p_, q_} :> p/iterlist[[q]]];
Attributes[myTiming] = {HoldAll};

myTiming[Sin[Range[1000]];]

```

> 
> First::normal: Nonatomic expression expected at position 1 in
> First[0.].
> 
> 
> First::normal: Nonatomic expression expected at position 1 in
> First[0.].
> 
> 
> First::normal: Nonatomic expression expected at position 1 in
> First[0.015625].
> 
> 
> General::stop: Further output of First::normal will be suppressed
> during this calculation.
> 
> 
> 

[![Errors generated in run-time when calling the function](https://i.stack.imgur.com/mmPJL.png)](https://i.stack.imgur.com/mmPJL.png)