Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -jobs option #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add -jobs option #105

wants to merge 2 commits into from

Conversation

hhatto
Copy link

@hhatto hhatto commented Jun 4, 2023

What's this?

enabled the -jobs option for performance enhancement when using the -w or -l option.

When a number greater than or equal to 2 is assigned to the -jobs option, an equivalent number of goroutine workers are launched.
These workers handle code formatting tasks, thereby parallelizing the process and enhancing performance as a result.

The results below demonstrate my use case both without the -jobs option and with the -jobs option set to 4.
I executed each of the -w or -l options three times in both scenarios.
There was approximately a 30% performance increase.

Cases without specifying -jobs option:

$ time golines -l ./
golines -l ./  72.06s user 252.78s system 1035% cpu 31.360 total
golines -l ./  68.15s user 232.71s system 1015% cpu 29.613 total
golines -l ./  71.16s user 251.04s system 1041% cpu 30.926 total

$ time golines -w ./
golines -w ./  64.21s user 227.85s system 1045% cpu 27.946 total
golines -w ./  65.72s user 221.50s system 965% cpu 29.762 total
golines -w ./  66.27s user 228.43s system 997% cpu 29.554 total

Cases with the -jobs option set to 4:

$ time ./golines.jobs -j 4 -l ./
./golines.jobs -j 4 -l ./  68.51s user 201.23s system 1403% cpu 19.219 total
./golines.jobs -j 4 -l ./  70.68s user 208.27s system 1380% cpu 20.204 total
./golines.jobs -j 4 -l ./  67.81s user 198.54s system 1406% cpu 18.942 total

$ time ./golines.jobs -j 4 -w ./
./golines.jobs -j 4 -w ./  70.34s user 207.37s system 1400% cpu 19.836 total
./golines.jobs -j 4 -w ./  72.11s user 212.88s system 1410% cpu 20.211 total
./golines.jobs -j 4 -w ./  70.00s user 205.18s system 1364% cpu 20.168 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant