Skip to main content
added 28 characters in body
Source Link
jdt
  • 4.5k
  • 1
  • 14
  • 18

c++, 332 358358 357 bytes

Thanks Adám!

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(109));n(e)t+=(e-s).count()/1e9;}int main(){int i;n(s)thread*a[6];forthread*a[7];for(i=0;i<6;i++i=0;i<7;i++)a[i]=new thread(f);for(i=0;i<6;i++i=0;i<7;i++)a[i]->join();n(e)cout<<t<<","<<(e-s).count()/1e9<<"\n";}

Try it onlineTry it online

c++, 332 358 bytes

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(10));n(e)t+=(e-s).count()/1e9;}int main(){int i;n(s)thread*a[6];for(i=0;i<6;i++)a[i]=new thread(f);for(i=0;i<6;i++)a[i]->join();n(e)cout<<t<<","<<(e-s).count()/1e9<<"\n";}

Try it online

c++, 332 358 357 bytes

Thanks Adám!

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(9));n(e)t+=(e-s).count()/1e9;}int main(){int i;n(s)thread*a[7];for(i=0;i<7;i++)a[i]=new thread(f);for(i=0;i<7;i++)a[i]->join();n(e)cout<<t<<","<<(e-s).count()/1e9<<"\n";}

Try it online

added 48 characters in body
Source Link
jdt
  • 4.5k
  • 1
  • 14
  • 18

c++, 332332 358 bytes

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(10));n(e)t+=(e-s).count()/1e9;}int main(){int i;thread*a[20];fori;n(i=0;i<20;i++s)thread*a[6];for(i=0;i<6;i++)a[i]=new thread(f);for(i=0;i<20;i++i=0;i<6;i++)a[i]->join();cout<<t<<"sec\n";;n(e)cout<<t<<","<<(e-s).count()/1e9<<"\n";}

Try it onlineTry it online

c++, 332 bytes

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(10));n(e)t+=(e-s).count()/1e9;}int main(){int i;thread*a[20];for(i=0;i<20;i++)a[i]=new thread(f);for(i=0;i<20;i++)a[i]->join();cout<<t<<"sec\n";}

Try it online

c++, 332 358 bytes

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(10));n(e)t+=(e-s).count()/1e9;}int main(){int i;n(s)thread*a[6];for(i=0;i<6;i++)a[i]=new thread(f);for(i=0;i<6;i++)a[i]->join();n(e)cout<<t<<","<<(e-s).count()/1e9<<"\n";}

Try it online

Source Link
jdt
  • 4.5k
  • 1
  • 14
  • 18

c++, 332 bytes

#include <iostream>
#include <chrono>
#include <thread>
#define n(x)auto x=chrono::steady_clock::now();
using namespace std;double t=0;void f(){n(s)this_thread::sleep_for(chrono::seconds(10));n(e)t+=(e-s).count()/1e9;}int main(){int i;thread*a[20];for(i=0;i<20;i++)a[i]=new thread(f);for(i=0;i<20;i++)a[i]->join();cout<<t<<"sec\n";}

Try it online