mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-10-04 06:56:29 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
48e150036d | ||
![]() |
486b767a25 | ||
![]() |
5a2e68bf92 | ||
![]() |
97d05f4b57 |
@@ -1,17 +1,17 @@
|
||||
package cputest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/oneclickvirt/cputest/cpu"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/oneclickvirt/cputest/cpu"
|
||||
)
|
||||
|
||||
func CpuTest(language, testMethod, testThread string) {
|
||||
var res string
|
||||
func CpuTest(language, testMethod, testThread string) (realTestMethod, res string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
if testMethod != "winsat" && testMethod != "" {
|
||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
||||
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||
realTestMethod = "winsat"
|
||||
}
|
||||
res += cpu.WinsatTest(language, testThread)
|
||||
} else {
|
||||
@@ -19,14 +19,20 @@ func CpuTest(language, testMethod, testThread string) {
|
||||
case "sysbench":
|
||||
res = cpu.SysBenchTest(language, testThread)
|
||||
if res == "" {
|
||||
res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
||||
// res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
||||
realTestMethod = "geekbench"
|
||||
res += cpu.GeekBenchTest(language, testThread)
|
||||
} else {
|
||||
realTestMethod = "sysbench"
|
||||
}
|
||||
case "geekbench":
|
||||
res = cpu.GeekBenchTest(language, testThread)
|
||||
if res == "" {
|
||||
res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
||||
// res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
||||
realTestMethod = "sysbench"
|
||||
res += cpu.SysBenchTest(language, testThread)
|
||||
} else {
|
||||
realTestMethod = "geekbench"
|
||||
}
|
||||
default:
|
||||
res = "Invalid test method specified.\n"
|
||||
@@ -35,5 +41,5 @@ func CpuTest(language, testMethod, testThread string) {
|
||||
if !strings.Contains(res, "\n") && res != "" {
|
||||
res += "\n"
|
||||
}
|
||||
fmt.Print(res)
|
||||
return
|
||||
}
|
||||
|
14
goecs.go
14
goecs.go
@@ -39,7 +39,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ecsVersion = "v0.1.52"
|
||||
ecsVersion = "v0.1.53"
|
||||
menuMode bool
|
||||
onlyChinaTest bool
|
||||
input, choice string
|
||||
@@ -396,7 +396,6 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
||||
seconds := int(duration.Seconds()) % 60
|
||||
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
||||
outputMutex.Lock()
|
||||
finalOutput := *output
|
||||
*output = utils.PrintAndCapture(func() {
|
||||
utils.PrintCenteredTitle("", width)
|
||||
if language == "zh" {
|
||||
@@ -407,8 +406,8 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
||||
fmt.Printf("Current Time : %s\n", currentTime)
|
||||
}
|
||||
utils.PrintCenteredTitle("", width)
|
||||
}, tempOutput, finalOutput)
|
||||
finalOutput = *output
|
||||
}, tempOutput, *output)
|
||||
finalOutput := *output
|
||||
outputMutex.Unlock()
|
||||
resultChan := make(chan struct {
|
||||
httpURL string
|
||||
@@ -571,12 +570,13 @@ func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||
_ = outputMutex
|
||||
return utils.PrintAndCapture(func() {
|
||||
if cpuTestStatus {
|
||||
realTestMethod, res := cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||
if language == "zh" {
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), width)
|
||||
} else {
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", cpuTestMethod), width)
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", realTestMethod), width)
|
||||
}
|
||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||
fmt.Print(res)
|
||||
}
|
||||
}, tempOutput, output)
|
||||
}
|
||||
|
6
goecs.sh
6
goecs.sh
@@ -143,7 +143,7 @@ goecs_check() {
|
||||
os=$(uname -s 2>/dev/null || echo "Unknown")
|
||||
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
||||
check_china
|
||||
ECS_VERSION="0.1.51"
|
||||
ECS_VERSION="0.1.52"
|
||||
for api in \
|
||||
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
||||
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
||||
@@ -155,8 +155,8 @@ goecs_check() {
|
||||
sleep 1
|
||||
done
|
||||
if [ -z "$ECS_VERSION" ]; then
|
||||
_yellow "Unable to get version info, using default version 0.1.51"
|
||||
ECS_VERSION="0.1.51"
|
||||
_yellow "Unable to get version info, using default version 0.1.52"
|
||||
ECS_VERSION="0.1.52"
|
||||
fi
|
||||
version_output=""
|
||||
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
||||
|
Reference in New Issue
Block a user