Skip to content

Conversation

@yzang2019
Copy link
Collaborator

Describe your changes and provide context

Testing performed to validate your change

@yzang2019 yzang2019 changed the title Add contract count Enhance state size analysis tool for more stats Aug 13, 2025
@yzang2019 yzang2019 requested a review from blindchaser August 13, 2025 22:40
kvTotalSize := keySize + valueSize
percentage := 0.0
if stats.totalSize > 0 {
percentage = float64(kvTotalSize) / float64(stats.totalSize) * 100

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
kvTotalSize := keySize + valueSize
percentage := 0.0
if stats.totalSize > 0 {
percentage = float64(kvTotalSize) / float64(stats.totalSize) * 100

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
Comment on lines +344 to +346
for _, entry := range stats.contractSizes {
sortedContracts = append(sortedContracts, *entry)
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +379 to +381
for _, ps := range projectSizes {
projList = append(projList, *ps)
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
Comment on lines +415 to +434
for _, c := range stats.contractSizes {
size := c.TotalSize
switch {
case size < 1*KB:
lt1KBCount++
lt1KBSizeBytes += size
case size >= 1*KB && size < 1*MB:
_1KBto1MBCount++
_1KBto1MBSizeBytes += size
case size >= 1*MB && size < 10*MB:
_1MBto10MBCount++
_1MBto10MBSizeBytes += size
case size >= 10*MB && size <= 100*MB:
_10MBto100Count++
_10MBto100SizeBytes += size
default: // > 100MB
gt100MBCount++
gt100MBSizeBytes += size
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
countPct := float64(count) / float64(total) * 100
sizePct := 0.0
if sumSizeBytes > 0 {
sizePct = float64(sizeBytes) / float64(sumSizeBytes) * 100

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
countPct := float64(count) / float64(total) * 100
sizePct := 0.0
if sumSizeBytes > 0 {
sizePct = float64(sizeBytes) / float64(sumSizeBytes) * 100

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
// Totals row and module share
fmt.Printf("%-20s %10d %8.2f %15d %7.2f\n", "Total", total, 100.00, sumSizeBytes/MB, 100.00)
if stats.totalSize > 0 {
share := float64(sumSizeBytes) / float64(stats.totalSize) * 100

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
// Totals row and module share
fmt.Printf("%-20s %10d %8.2f %15d %7.2f\n", "Total", total, 100.00, sumSizeBytes/MB, 100.00)
if stats.totalSize > 0 {
share := float64(sumSizeBytes) / float64(stats.totalSize) * 100

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
Comment on lines +465 to +470
for proj, addrs := range ProjectContracts {
for _, a := range addrs {
key := strings.ToLower(a) // keep "0x" prefix
addrToProjects[key] = append(addrToProjects[key], proj)
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning

Iteration over map may be a possible source of non-determinism
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.

3 participants