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

[ISSUE #7868] Use entrySet to close channel #7869

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

ChineseTony
Copy link
Contributor

Which Issue(s) This PR Fixes

Fixes #7868

Brief Description

How Did You Test This Change?

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 42.93%. Comparing base (471dbc0) to head (c875de2).
Report is 1 commits behind head on develop.

Files Patch % Lines
...e/rocketmq/remoting/netty/NettyRemotingClient.java 40.00% 3 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #7869      +/-   ##
=============================================
- Coverage      42.95%   42.93%   -0.03%     
- Complexity      9913     9916       +3     
=============================================
  Files           1190     1190              
  Lines          86016    86017       +1     
  Branches       11080    11080              
=============================================
- Hits           36948    36929      -19     
- Misses         44495    44522      +27     
+ Partials        4573     4566       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glcrazier
Copy link
Contributor

Do you have any statistical support for this enhancement?

@ChineseTony
Copy link
Contributor Author

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 3, time = 1)
@Measurement(iterations = 5, time = 3)
@Fork(1)
@State(value = Scope.Benchmark)
@OutputTimeUnit(TimeUnit.SECONDS)

public class MapUtil {
    private Map<String, String> map = new HashMap<>();

    @Setup
    public void setup() {
        for (int i = 0; i < 8000; i++) {
            map.put(i + "", i + "");
        }
    }

    @Benchmark
    @Threads(8)
    public void keySetMap() {
        keySet();
    }

    @Benchmark
    @Threads(8)
    public void entrySetMap() {
        entrySet();
    }

    private void entrySet() {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            entry.getValue();
        }
    }

    private void keySet() {
        for (String key : map.keySet()) {
            map.get(key);
        }
    }
}

Benchmark Mode Cnt Score Error Units
MapUtil.entrySetMap thrpt 5 172067.111 ± 452324.484 ops/s
MapUtil.keySetMap thrpt 5 109211.325 ± 41925.022 ops/s

@RongtongJin RongtongJin merged commit af900e9 into apache:develop Feb 29, 2024
9 of 10 checks passed
@ChineseTony ChineseTony deleted the use_entryset_foreach branch March 13, 2024 15:00
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.

[Enhancement] using entryset iterator map
4 participants