From d92c1641ac80011905e49cd3ab6f17914a95e55b Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 24 Jan 2022 12:39:27 +0100 Subject: [PATCH] feat: start adding torsf to desktop and mobile (#671) This commit message is the same across probe-cli, probe-desktop, and probe-android. With the changes contained in the enclosed diff, I'm starting to add support for torsf for android and for desktop. When smoke testing that torsf was WAI, I also noticed that its progress messages in output are too frequent. We may want to do better in a future version when we'll be able to read `tor`'s output. In the meanwhile, make the progress messages less frequent and indicated the maximum runtime inside of the messages themselves. This improved message, albeit not so nice from the UX PoV, should at least provide a clue that we're not stuck. Reference issue: https://github.com/ooni/probe/issues/1917 --- internal/engine/experiment/torsf/torsf.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/engine/experiment/torsf/torsf.go b/internal/engine/experiment/torsf/torsf.go index e850953..a96b466 100644 --- a/internal/engine/experiment/torsf/torsf.go +++ b/internal/engine/experiment/torsf/torsf.go @@ -6,6 +6,7 @@ package torsf import ( "context" + "fmt" "path" "time" @@ -80,7 +81,7 @@ func (m *Measurer) Run( ctx, cancel := context.WithTimeout(ctx, maxRuntime) defer cancel() errch := make(chan error) - ticker := time.NewTicker(250 * time.Millisecond) + ticker := time.NewTicker(2 * time.Second) defer ticker.Stop() go m.run(ctx, sess, testkeys, errch) for { @@ -90,8 +91,11 @@ func (m *Measurer) Run( return err case <-ticker.C: if !m.config.DisableProgress { - progress := time.Since(start).Seconds() / maxRuntime.Seconds() - callbacks.OnProgress(progress, "torsf experiment is running") + elapsedTime := time.Since(start) + progress := elapsedTime.Seconds() / maxRuntime.Seconds() + callbacks.OnProgress(progress, fmt.Sprintf( + "torsf: elapsedTime: %.0f s; maxRuntime: %.0f s", + elapsedTime.Seconds(), maxRuntime.Seconds())) } } }