Skip to main content
Added explanation
Source Link

Perl 6, 45 bytes

.put for -($_=1e3)..$_;put (now -INIT now)*$_

Try it

Expanded:

# print the values

.put             # print with trailing newline ( method call on 「$_」 )

for              # for each of the following
                 # ( temporarily sets 「$_」 to the value )

-(
  $_ = 1e3       # store 「Num(1000)」 in 「$_」
)
..               # inclusive Range object
$_;

# print the time elapsed

put              # print with trailing newline

(now - INIT now) # Duration object that numifies to elapsed seconds
* $_             # times 1000 to bring it to milliseconds

# The 「INIT」 phaser runs code (the second 「now」) immediately
# as the program starts.

# There is no otherwise unrelated set-up in this code so this is a
# reliable indicator of the amount of time it takes to print the values.

Perl 6, 45 bytes

.put for -($_=1e3)..$_;put (now -INIT now)*$_

Try it

Perl 6, 45 bytes

.put for -($_=1e3)..$_;put (now -INIT now)*$_

Try it

Expanded:

# print the values

.put             # print with trailing newline ( method call on 「$_」 )

for              # for each of the following
                 # ( temporarily sets 「$_」 to the value )

-(
  $_ = 1e3       # store 「Num(1000)」 in 「$_」
)
..               # inclusive Range object
$_;

# print the time elapsed

put              # print with trailing newline

(now - INIT now) # Duration object that numifies to elapsed seconds
* $_             # times 1000 to bring it to milliseconds

# The 「INIT」 phaser runs code (the second 「now」) immediately
# as the program starts.

# There is no otherwise unrelated set-up in this code so this is a
# reliable indicator of the amount of time it takes to print the values.
Source Link

Perl 6, 45 bytes

.put for -($_=1e3)..$_;put (now -INIT now)*$_

Try it