Skip to content

Commit ec3c6ec

Browse files
committed
change: remove saving-mode to userconfig
1 parent df79bf4 commit ec3c6ec

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Flags:
3535
-l, --list Show available speedtest.net servers.
3636
-s, --server=SERVER ... Select server id to speedtest.
3737
--custom-url=CUSTOM-URL Specify the url of the server instead of getting a list from speedtest.net.
38-
--saving-mode Test with few computing resources, though low accuracy (especially > 30Mbps).
38+
--saving-mode Test with few resources, though low accuracy (especially > 30Mbps).
3939
--json Output results in json format.
4040
--location=LOCATION Change the location with a precise coordinate.
4141
--city=CITY Change the location with a predefined city label.
@@ -185,8 +185,8 @@ func main() {
185185
// otherwise you will get an error.
186186
// It is recommended to replace a server at this time
187187
s.PingTest()
188-
s.DownloadTest(false)
189-
s.UploadTest(false)
188+
s.DownloadTest()
189+
s.UploadTest()
190190
fmt.Printf("Latency: %s, Download: %f, Upload: %f\n", s.Latency, s.DLSpeed, s.ULSpeed)
191191
}
192192
}

example/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func main() {
2323
// otherwise you will get an error.
2424
// It is recommended to replace a server at this time
2525
checkError(s.PingTest())
26-
checkError(s.DownloadTest(false))
27-
checkError(s.UploadTest(false))
26+
checkError(s.DownloadTest())
27+
checkError(s.UploadTest())
2828

2929
fmt.Printf("Latency: %s, Download: %f, Upload: %f\n", s.Latency, s.DLSpeed, s.ULSpeed)
3030
//speedtest.GlobalDataManager.Reset()

speedtest.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
showList = kingpin.Flag("list", "Show available speedtest.net servers.").Short('l').Bool()
1818
serverIds = kingpin.Flag("server", "Select server id to run speedtest.").Short('s').Ints()
1919
customURL = kingpin.Flag("custom-url", "Specify the url of the server instead of getting a list from speedtest.net.").String()
20-
savingMode = kingpin.Flag("saving-mode", "Test with few computing resources, though low accuracy (especially > 30Mbps).").Bool()
20+
savingMode = kingpin.Flag("saving-mode", "Test with few resources, though low accuracy (especially > 30Mbps).").Bool()
2121
jsonOutput = kingpin.Flag("json", "Output results in json format.").Bool()
2222
location = kingpin.Flag("location", "Change the location with a precise coordinate. Format: lat,lon").String()
2323
city = kingpin.Flag("city", "Change the location with a predefined city label.").String()
@@ -125,21 +125,21 @@ func startMultiTest(s *speedtest.Server, servers speedtest.Servers, savingMode b
125125
checkError(err)
126126

127127
if jsonOutput {
128-
err = s.MultiDownloadTestContext(context.Background(), servers, savingMode)
128+
err = s.MultiDownloadTestContext(context.Background(), servers)
129129
checkError(err)
130130
s.Context.Wait()
131-
err = s.MultiUploadTestContext(context.Background(), servers, savingMode)
131+
err = s.MultiUploadTestContext(context.Background(), servers)
132132
checkError(err)
133133
return
134134
}
135135

136136
showLatencyResult(s)
137-
err = testDownloadM(s, servers, savingMode)
137+
err = testDownloadM(s, servers)
138138
checkError(err)
139139
// It is necessary to wait for the release of the last test resource,
140140
// otherwise the overload will cause excessive data deviation
141141
s.Context.Wait()
142-
err = testUploadM(s, servers, savingMode)
142+
err = testUploadM(s, servers)
143143
checkError(err)
144144
showServerResult(s)
145145
}
@@ -156,22 +156,22 @@ func startTest(servers speedtest.Servers, savingMode bool, jsonOutput bool) {
156156
checkError(err)
157157

158158
if jsonOutput {
159-
err = s.DownloadTest(savingMode)
159+
err = s.DownloadTest()
160160
checkError(err)
161161
s.Context.Wait()
162-
err = s.UploadTest(savingMode)
162+
err = s.UploadTest()
163163
checkError(err)
164164
continue
165165
}
166166

167167
showLatencyResult(s)
168168

169-
err = testDownload(s, savingMode)
169+
err = testDownload(s)
170170
checkError(err)
171171
// It is necessary to wait for the release of the last test resource,
172172
// otherwise the overload will cause excessive data deviation
173173
s.Context.Wait()
174-
err = testUpload(s, savingMode)
174+
err = testUpload(s)
175175
checkError(err)
176176
showServerResult(s)
177177
}
@@ -181,11 +181,11 @@ func startTest(servers speedtest.Servers, savingMode bool, jsonOutput bool) {
181181
}
182182
}
183183

184-
func testDownloadM(server *speedtest.Server, servers speedtest.Servers, savingMode bool) error {
184+
func testDownloadM(server *speedtest.Server, servers speedtest.Servers) error {
185185
quit := make(chan bool)
186186
fmt.Printf("Download Test: ")
187187
go dots(quit)
188-
err := server.MultiDownloadTestContext(context.Background(), servers, savingMode)
188+
err := server.MultiDownloadTestContext(context.Background(), servers)
189189
checkError(err)
190190
quit <- true
191191
if err != nil {
@@ -195,11 +195,11 @@ func testDownloadM(server *speedtest.Server, servers speedtest.Servers, savingMo
195195
return err
196196
}
197197

198-
func testUploadM(server *speedtest.Server, servers speedtest.Servers, savingMode bool) error {
198+
func testUploadM(server *speedtest.Server, servers speedtest.Servers) error {
199199
quit := make(chan bool)
200200
fmt.Printf("Upload Test: ")
201201
go dots(quit)
202-
err := server.MultiUploadTestContext(context.Background(), servers, savingMode)
202+
err := server.MultiUploadTestContext(context.Background(), servers)
203203
checkError(err)
204204
quit <- true
205205
if err != nil {
@@ -209,11 +209,11 @@ func testUploadM(server *speedtest.Server, servers speedtest.Servers, savingMode
209209
return nil
210210
}
211211

212-
func testDownload(server *speedtest.Server, savingMode bool) error {
212+
func testDownload(server *speedtest.Server) error {
213213
quit := make(chan bool)
214214
fmt.Printf("Download Test: ")
215215
go dots(quit)
216-
err := server.DownloadTest(savingMode)
216+
err := server.DownloadTest()
217217
quit <- true
218218
if err != nil {
219219
return err
@@ -222,11 +222,11 @@ func testDownload(server *speedtest.Server, savingMode bool) error {
222222
return err
223223
}
224224

225-
func testUpload(server *speedtest.Server, savingMode bool) error {
225+
func testUpload(server *speedtest.Server) error {
226226
quit := make(chan bool)
227227
fmt.Printf("Upload Test: ")
228228
go dots(quit)
229-
err := server.UploadTest(savingMode)
229+
err := server.UploadTest()
230230
quit <- true
231231
if err != nil {
232232
return err

speedtest/request.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222
ulSizes = [...]int{100, 300, 500, 800, 1000, 1500, 2500, 3000, 3500, 4000} // kB
2323
)
2424

25-
func (s *Server) MultiDownloadTestContext(ctx context.Context, servers Servers, savingMode bool) error {
25+
func (s *Server) MultiDownloadTestContext(ctx context.Context, servers Servers) error {
2626
if s.Context.config.NoDownload {
2727
dbg.Println("Download test disabled")
2828
return nil
@@ -49,7 +49,7 @@ func (s *Server) MultiDownloadTestContext(ctx context.Context, servers Servers,
4949
return nil
5050
}
5151

52-
func (s *Server) MultiUploadTestContext(ctx context.Context, servers Servers, savingMode bool) error {
52+
func (s *Server) MultiUploadTestContext(ctx context.Context, servers Servers) error {
5353
if s.Context.config.NoUpload {
5454
dbg.Println("Upload test disabled")
5555
return nil
@@ -77,7 +77,7 @@ func (s *Server) MultiUploadTestContext(ctx context.Context, servers Servers, sa
7777
}
7878

7979
// DownloadTest executes the test to measure download speed
80-
func (s *Server) DownloadTest(savingMode bool) error {
80+
func (s *Server) DownloadTest() error {
8181
return s.downloadTestContext(context.Background(), downloadRequest)
8282
}
8383

@@ -100,12 +100,12 @@ func (s *Server) downloadTestContext(ctx context.Context, downloadRequest downlo
100100
}
101101

102102
// UploadTest executes the test to measure upload speed
103-
func (s *Server) UploadTest(savingMode bool) error {
103+
func (s *Server) UploadTest() error {
104104
return s.uploadTestContext(context.Background(), uploadRequest)
105105
}
106106

107107
// UploadTestContext executes the test to measure upload speed, observing the given context.
108-
func (s *Server) UploadTestContext(ctx context.Context, savingMode bool) error {
108+
func (s *Server) UploadTestContext(ctx context.Context) error {
109109
return s.uploadTestContext(ctx, uploadRequest)
110110
}
111111

speedtest/speedtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
var (
16-
version = "1.5.1"
16+
version = "1.5.2"
1717
DefaultUserAgent = fmt.Sprintf("showwin/speedtest-go %s", version)
1818
)
1919

0 commit comments

Comments
 (0)