Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
RongtongJin merged 1 commit intoapache:developapache/rocketmq:developfrom
ChineseTony:use_entryset_foreachChineseTony/rocketmq:use_entryset_foreachCopy head branch name to clipboard
Feb 29, 2024
Merged

[ISSUE #7868] Use entrySet to close channel#7869
RongtongJin merged 1 commit intoapache:developapache/rocketmq:developfrom
ChineseTony:use_entryset_foreachChineseTony/rocketmq:use_entryset_foreachCopy head branch name to clipboard

Conversation

@ChineseTony
Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #7868

Brief Description

How Did You Test This Change?

@codecov-commenter
Copy link
Copy Markdown

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
Copy Markdown
Contributor

Do you have any statistical support for this enhancement?

@ChineseTony
Copy link
Copy Markdown
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
@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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.