kgiannis / go_goroutines_example

GoRoutines example with timings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoRoutines example with timings

In this example I am demonstrating the usage of GoRoutines.
As you can see with the recorded timings, more than one CPU core is used here.

Program execution

The program flow is as follows:

  • Print time of execution start in console
  • Repeat GoRoutine calls
  • Pause execution in order for the GoRoutines to complete
  • Print time of execution stop in console

SOS! pause execution time must be greater than repeat call time

Console Output

A sample of console output is shown here

2019-03-12 13:45:08.8492231 +0200 EET m=+0.001001101 - Start
2019-03-12 13:45:10.8548423 +0200 EET m=+2.006555901 - repeater_2
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_13
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_10
2019-03-12 13:45:10.8548423 +0200 EET m=+2.006555901 - repeater_5
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_19
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_7
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_6
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_8
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_1
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_14
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_4
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_18
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_3
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_17
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_16
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_15
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_11
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_9
2019-03-12 13:45:10.854973 +0200 EET m=+2.006686701 - repeater_0
2019-03-12 13:45:10.8548423 +0200 EET m=+2.006555901 - repeater_12
2019-03-12 13:45:11.8561176 +0200 EET m=+3.007799101 - End

About

GoRoutines example with timings


Languages

Language:Go 100.0%