speedy-js / benchmarks

1 stars 0 forks source link

feat: add callback for setupTask #10

Closed bvanjoi closed 1 year ago

bvanjoi commented 2 years ago

Sometimes we may need change config after genXxxxConfig, so we may need append a callback after setup .

For example, if we want to change speedy config:

  1. read config from task: https://github.com/speedy-js/benchmarks/compare/main...bvanjoi:callback_for_setupTask?expand=1#diff-55d1354a0b2c73c274b747e6af0d8b7436ffa6595d495dbcb5bb03d0d727622dR109
  2. change it using callback: https://github.com/speedy-js/benchmarks/compare/main...bvanjoi:callback_for_setupTask?expand=1#diff-55d1354a0b2c73c274b747e6af0d8b7436ffa6595d495dbcb5bb03d0d727622dR127
hyf0 commented 2 years ago

Sometimes we may need change config after genXxxxConfig, so we may need append a callback after setup .

Could you explain when we need this? The example seems not to be convincing.

bvanjoi commented 2 years ago

First, callback is used to add or remove certain configuration items to the config generated by Task under the project.

Second, suppose I want to add some configuration items for benchmark tests, there are two options.

  1. adding some additional projects with different configuration files.
  2. reuse the existing projects, but change some configuration for a period of time.

I choose option 2, which is the reason for adding callback.

hyf0 commented 2 years ago

Got it. The current solution is option1. It makes generating benchmark reports very straightforward and easy to understand. A project with a task.config.js represents a report.

I tend to not modify Config generated by task.config.ts. A task.config.ts represents a Config and there shouldn't have any condition to modify it, which means it should be pure.