-
Notifications
You must be signed in to change notification settings - Fork 239
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
Improve performance #149
Improve performance #149
Conversation
Co-authored-by: Aswin Karthik <aswinkarthik93@gmail.com> Signed-off-by: Dinesh <dineshudt17@gmail.com>
Co-authored-by: Aswin Karthik <aswinkarthik93@gmail.com> Signed-off-by: Dinesh <dineshudt17@gmail.com>
Signed-off-by: Dinesh <dineshudt17@gmail.com> Co-authored-by: Aswin Karthik <aswinkarthik93@gmail.com>
detector/filecontent_detector.go
Outdated
} | ||
contents <- content{ | ||
name: addition.Name, | ||
path: addition.Path, | ||
contentType: base64Content, | ||
results: fc.detectFile(addition.Data, checkBase64), | ||
} | ||
contents <- content{ | ||
name: addition.Name, | ||
path: addition.Path, | ||
contentType: hexContent, | ||
results: fc.detectFile(addition.Data, checkHex), | ||
} | ||
contents <- content{ | ||
name: addition.Name, | ||
path: addition.Path, | ||
contentType: creditCardContent, | ||
results: fc.detectFile(addition.Data, checkCreditCardNumber), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lot of repeated code here.
I wonder if repetition could be avoided ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 96 to 112, we are just creating 3 structs and sending to channel. I am not very sure how to reduce that. If you have any idea, please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored this. Please review it
Signed-off-by: Dinesh <dineshudt17@gmail.com>
Signed-off-by: Dinesh <dineshudt17@gmail.com>
Signed-off-by: Dinesh <dineshudt17@gmail.com>
This will help to close this #152 |
I haven't checked the PR completely. But from an overview, I'm just curious about tests for this PR. Tests for the happy path and to show that performance has increased. Like, how do I say if my performance has increased by this PR, and how do I know if it gets decreased by some other code later? I haven't done such testing before, just curious. Some ideas - probably do some profiling? Or use some other parameter that relates to performance and check it? |
@karuppiah7890 are you saying we need to add tests to the test suite ? |
If it's possible, yes. I mean, I would need some measure to say the performance has increased, it can be in any form. Numbers always speak for themselves. Or else we will never know how much performant the code is compared to before. And such a metric would be useful in the future too |
Does this help at all ? https://stackoverflow.com/questions/13003749/number-of-elements-in-a-channel |
https://tour.golang.org/concurrency/4 |
We are reading from two channels simultaneously. So we have to use |
@dineshba : The two processing methods seem to have the same signature. |
Co-authored-by: @aswinkarthik
We introduced
go routines
in pattern detector and file content detector tomake things in parallel.
Results:
For a codebase which had 600 newly added files
Before our change:
After our change:
Method level metrics: