-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add code size analyzer #109
Conversation
Reviewer's Guide by SourceryThis PR implements a code size analyzer feature that tracks and reports bundle size metrics before and after obfuscation. The implementation includes a new CodeSizeAnalyzer class that calculates both raw and gzipped sizes of bundles, and presents the results with percentage changes. Class diagram for CodeSizeAnalyzer and related typesclassDiagram
class CodeSizeAnalyzer {
- Log _log
- SizeResult originalSize
- SizeResult obfuscatedSize
- number startTime
- number endTime
+ CodeSizeAnalyzer(Log log)
+ void start(BundleList originalBundleList)
+ void end(BundleList obfuscatedBundleList)
- SizeResult calculateBundleSize(BundleList bundleList)
- string analyze()
- void logResult()
- SizeResult createEmptySizeResult()
}
class SizeResult {
FormatSizeResult original
FormatSizeResult gzip
}
class FormatSizeResult {
number value
SizeUnit unit
}
class SizeUnit {
<<enumeration>>
B
KB
MB
}
CodeSizeAnalyzer --> Log
CodeSizeAnalyzer --> SizeResult
SizeResult --> FormatSizeResult
FormatSizeResult --> SizeUnit
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @z0ffy - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
const percentageIncrease = ( | ||
((obfuscatedSize.original.value - originalSize.original.value) / originalSize.original.value) | ||
* 100 | ||
).toFixed(2); |
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.
issue: Handle edge cases where original sizes are 0 to prevent NaN or Infinity results
Add checks before division to handle cases where originalSize values are 0. Consider returning '0%' or 'N/A' in such cases.
Summary by Sourcery
Add a code size analyzer to measure and log the size of code bundles before and after obfuscation, including gzip sizes. Enhance the logging of the obfuscation process with detailed size information.
New Features:
Enhancements: