Skip to content

Commit 0252e6b

Browse files
committed
refactor(main): cleanup, use internal/fast instead
1 parent a6803e9 commit 0252e6b

File tree

1 file changed

+2
-46
lines changed

1 file changed

+2
-46
lines changed

main.go

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,9 @@
11
package main
22

33
import (
4-
"context"
5-
"fmt"
6-
"log"
7-
"time"
8-
9-
"github.com/chromedp/chromedp"
10-
"github.com/chromedp/cdproto/emulation"
4+
"github.com/adhocore/fast/internal/fast"
115
)
126

137
func main() {
14-
ctx, cancel := chromedp.NewContext(
15-
context.Background(),
16-
chromedp.WithLogf(log.Printf),
17-
)
18-
defer cancel()
19-
20-
ctx, cancel = context.WithTimeout(ctx, 60*time.Second)
21-
defer cancel()
22-
23-
start := time.Now()
24-
25-
var (
26-
up string
27-
dw string
28-
upunit string
29-
dwunit string
30-
)
31-
32-
err := chromedp.Run(ctx,
33-
emulation.SetUserAgentOverride(`chromedp/chromedp v0.6.10`),
34-
chromedp.Navigate(`https://fast.com`),
35-
chromedp.ScrollIntoView(`footer`),
36-
chromedp.WaitVisible(`#speed-value.succeeded`),
37-
chromedp.Text(`#speed-value.succeeded`, &dw, chromedp.NodeVisible, chromedp.ByQuery),
38-
chromedp.Text(`#speed-units.succeeded`, &dwunit, chromedp.NodeVisible, chromedp.ByQuery),
39-
chromedp.Click(`#show-more-details-link`),
40-
chromedp.WaitVisible(`#upload-value.succeeded`),
41-
chromedp.Text(`#upload-value.succeeded`, &up, chromedp.NodeVisible, chromedp.ByQuery),
42-
chromedp.Text(`#upload-units.succeeded`, &upunit, chromedp.NodeVisible, chromedp.ByQuery),
43-
)
44-
45-
if err != nil {
46-
log.Fatal(err)
47-
}
48-
49-
fmt.Printf("\033[36mdownload speed:\033[m \033[32m%s\033[m %s\n", dw, dwunit)
50-
fmt.Printf("\033[36mupload speed:\033[m \033[31m%s\033[m %s\n", up, upunit)
51-
fmt.Printf("\n")
52-
fmt.Printf("\033[36m> took: \033[33m%f\033[m secs\n", time.Since(start).Seconds())
8+
fast.Run()
539
}

0 commit comments

Comments
 (0)