Compare commits

...

4 Commits

Author SHA1 Message Date
04e5b5f3eb
Merge pull request #56 from aykhans/bump/version
Bump version to 0.5.3
2024-12-18 00:15:42 +04:00
2bebf09adb
Bump version to 0.5.3 2024-12-18 00:15:31 +04:00
ebacebff16
Merge pull request #55 from aykhans/refactor/response-struct
🔨 Reduce memory usage of the 'Response' struct
2024-12-17 23:22:30 +04:00
575ca2913a 🔨 Reduce memory usage of the 'Response' struct 2024-12-17 23:07:25 +04:00
3 changed files with 12 additions and 22 deletions

View File

@ -12,7 +12,7 @@ import (
)
const (
VERSION string = "0.5.2"
VERSION string = "0.5.3"
DefaultUserAgent string = "Dodo/" + VERSION
ProxyCheckURL string = "https://www.google.com"
DefaultMethod string = "GET"

View File

@ -1,7 +1,6 @@
package requests
import (
"fmt"
"os"
"time"
@ -10,8 +9,7 @@ import (
)
type Response struct {
StatusCode int
Error error
Response string
Time time.Duration
}
@ -45,17 +43,10 @@ func (respones Responses) Print() {
}
total.Sum += response.Time
if response.Error != nil {
mergedResponses[response.Error.Error()] = append(
mergedResponses[response.Error.Error()],
mergedResponses[response.Response] = append(
mergedResponses[response.Response],
response.Time,
)
} else {
mergedResponses[fmt.Sprintf("%d", response.StatusCode)] = append(
mergedResponses[fmt.Sprintf("%d", response.StatusCode)],
response.Time,
)
}
allDurations = append(allDurations, response.Time)
}
allDurations.Sort()

View File

@ -2,6 +2,7 @@ package requests
import (
"context"
"strconv"
"sync"
"time"
@ -142,8 +143,7 @@ func sendRequest(
return
}
*responseData = append(*responseData, &Response{
StatusCode: 0,
Error: err,
Response: err.Error(),
Time: completedTime,
})
increase <- 1
@ -151,8 +151,7 @@ func sendRequest(
}
*responseData = append(*responseData, &Response{
StatusCode: response.StatusCode(),
Error: nil,
Response: strconv.Itoa(response.StatusCode()),
Time: completedTime,
})
increase <- 1