diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index f3a60e1dd0..b63b35c83e 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -88,20 +88,11 @@ jobs: path: ./cache key: ${{ runner.os }}-benchmark -<<<<<<< HEAD - - name: Store benchmark result -======= - name: Store benchmark result iLogtail ->>>>>>> a9705b46 (update github benchmark CI to store avg/max ans time records) uses: benchmark-action/github-action-benchmark@v1 with: name: benchmark tool: "customSmallerIsBetter" -<<<<<<< HEAD - output-file-path: "test/benchmark/report/combined_benchmark.json" - external-data-json-path: ./cache/benchmark-data.json - summary-always: true -======= output-file-path: "test/benchmark/report/ilogtail_statistic_all.json" external-data-json-path: ./cache/ilogtail_statistic.json auto-push: false @@ -120,8 +111,6 @@ jobs: # - name: Push benchmark result # run: git push 'https://alibaba:${{ secrets.GITHUB_TOKEN }}@github.com/alibaba/ilogtail.git' gh-pages:gh-pages ->>>>>>> a9705b46 (update github benchmark CI to store avg/max ans time records) - result: if: github.event.pull_request.merged == true runs-on: ubuntu-latest @@ -129,4 +118,4 @@ jobs: needs: [ CI ] steps: - name: Build Result - run: echo "Just to make the GitHub merge button green" \ No newline at end of file + run: echo "Just to make the GitHub merge button green" diff --git a/test/engine/trigger/file.go b/test/engine/trigger/file.go index ceab6e5cf0..aaa47deb3f 100644 --- a/test/engine/trigger/file.go +++ b/test/engine/trigger/file.go @@ -2,9 +2,7 @@ package trigger import ( "context" - "fmt" "os" - "os/exec" "path/filepath" "time" @@ -18,13 +16,9 @@ func GenerateLogToFile(ctx context.Context, speed, totalTime int, path string, t path = filepath.Join(config.CaseHome, path) path = filepath.Clean(path) _ = os.WriteFile(path, []byte{}, 0600) + file, _ := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) // #nosec G304 - command := fmt.Sprintf("echo '%s' >> %s", templateStr, path) - - // interval = templateLen / speed - interval := time.Microsecond * time.Duration(len(templateStr)/speed) - - limiter := rate.NewLimiter(rate.Every(interval), 1) + limiter := rate.NewLimiter(rate.Limit(speed*1024*1024), len(templateStr)) timeout := time.After(time.Minute * time.Duration(totalTime)) @@ -33,19 +27,17 @@ func GenerateLogToFile(ctx context.Context, speed, totalTime int, path string, t // context is done case <-ctx.Done(): // clear file - _ = os.WriteFile(path, []byte{}, 0600) + _ = file.Close() return ctx, ctx.Err() // all time is done case <-timeout: // clear file - _ = os.WriteFile(path, []byte{}, 0600) + _ = file.Close() return ctx, nil default: - if err := limiter.Wait(ctx); err != nil { - return ctx, err + if limiter.AllowN(time.Now(), len(templateStr)) { + _, _ = file.WriteString(templateStr + "\n") } - cmd := exec.Command("sh", "-c", command) - _ = cmd.Run() } } }