Wait a minute – in less than ten seconds

Python 2, 172 bytes

import threading as H,time as T
m=T.time
z=H.Thread
s=m()
r=[]
def f():n=m();T.sleep(9);f.t+=m()-n
f.t=0
exec"r+=[z(None,f)];r[-1].start();"*8
map(z.join,r)
print m()-s,f.t

This requires an OS with time precision greater than 1 second to work properly (in other words, any modern OS). 8 threads are created which sleep for 9 seconds each, resulting in a realtime runtime of ~9 seconds, and a parallel runtime of ~72 seconds.

Though the official documentation says that the Thread constructor should be called with keyword arguments, I throw caution to the wind and use positional arguments anyway. The first argument (group) must be None, and the second argument is the target function.

nneonneo pointed out in the comments that attribute access (e.g. f.t) is shorter than list index access (e.g. t[0]). Unfortunately, in most cases, the few bytes gained from doing this would be lost by needing to create an object that allows user-defined attributes to be created at runtime. Luckily, functions support user-defined attributes at runtime, so I exploit this by saving the total time in the t attribute of f.

Try it online

Thanks to DenkerAffe for -5 bytes with the exec trick.

Thanks to kundor for -7 bytes by pointing out that the thread argument is unnecessary.

Thanks to nneonneo for -7 bytes from miscellaneous improvements.


Dyalog APL, 65 27 23 21 bytes

(⌈/,+/)⎕TSYNC⎕DL&¨9/7

I.e.:

      (⌈/,+/)⎕TSYNC⎕DL&¨9/7
7.022 63.162

Explanation:

  • ⎕DL&¨9/7: spin off 9 threads, each of which waits for 7 seconds. ⎕DL returns the actual amount of time spent waiting, in seconds, which will be the same as its argument give or take a few milliseconds.
  • ⎕TSYNC: wait for all threads to complete, and get the result for each thread.
  • (⌈/,+/): return the longest execution time of one single thread (during the execution of which all other threads finished, so this is the actual runtime), followed by the sum of the execution time of all threads.

Try it online!


Bash + GNU utilities, 85

\time -f%e bash -c 'for i in {1..8};{ \time -aoj -f%e sleep 8&};wait'
paste -sd+ j|bc

Forces the use of the time executable instead of the shell builtin by prefixing with a \.

Appends to a file j, which must be empty or non-existent at the start.