Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

pipeline

package main

import (
    "fmt"
    "time"
    "strconv"
)

// The pinger prints a ping and waits for a pong
func startLog(startTime time.Time, pinger <-chan int) {
        <-pinger
        fmt.Println("Start log:")
        fmt.Println(startTime)

}

// The ponger prints a pong and waits for a ping
func endLog(startTime time.Time, ponger <-chan int) {
        <-ponger
        endTime := time.Now()
        diffTime := endTime.UnixNano() - startTime.UnixNano()
        fmt.Println("End log: ")
        fmt.Println(endTime)
        fmt.Println("Execution time: " + strconv.FormatInt(diffTime, 10) + " nanoseconds")

    
}

func startLogThread(startTime time.Time) {
    ping := make(chan int)
    go startLog(startTime, ping)
    ping <- 1
    
}

func endLogThread(startTime time.Time) {
    pong := make(chan int)
    go endLog(startTime, pong)
    pong <- 1
}

func main() {
    startTime := time.Now()

    fmt.Println("Start test")
    fmt.Println("")

    startLogThread(startTime)
    fmt.Println("")

    fmt.Println("Function is needed to measure performance => HERE")
    fmt.Println("")

    endLogThread(startTime)
    
    fmt.Println("")
    fmt.Println("End test")

}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.