~humaid/ns2-trace-go

3f45f986a43ce7b76d5908c1026743645c691d95 — Humaid AlQassimi 1 year, 9 months ago c8c9b1d
Speed improvement with concurrency when generating statistics and calculating jitter
1 files changed, 11 insertions(+), 2 deletions(-)

M main.go
M main.go => main.go +11 -2
@@ 63,10 63,19 @@ func main() {
			ctx.PlainText(400, []byte(fmt.Sprintf("Failed to parse file: %s", err)))
			return
		}
		jsChan := make(chan []*JitterStat, 1)
		statsChan := make(chan TraceStats, 1)
		go func() {
			jsChan <- CalculateJitters(trace)
		}()
		go func() {
			statsChan <- CalculateStats(trace)
		}()

		Analysises[analysisID] = Analysis{
			Traces:      trace,
			JitterStats: CalculateJitters(trace),
			Stats:       CalculateStats(trace),
			JitterStats: <-jsChan,
			Stats:       <-statsChan,
		}
		ctx.Redirect(fmt.Sprintf("/%s", analysisID))
	})