public static void removeRedundantMinMaxMetrics(RuntimeProfile profile) {
        for (String name : profile.counterMap.keySet()) {
            Counter counter = profile.getCounter(name);
            Counter minCounter = profile.getCounter(MERGED_INFO_PREFIX_MIN + name);
            Counter maxCounter = profile.getCounter(MERGED_INFO_PREFIX_MAX + name);
            if (counter == null || minCounter == null || maxCounter == null) {
                continue;
            }

            if (Objects.equals(minCounter.getValue(), maxCounter.getValue()) &&
                    Objects.equals(minCounter.getValue(), counter.getValue())) {
                profile.removeCounter(MERGED_INFO_PREFIX_MIN + name);
                profile.removeCounter(MERGED_INFO_PREFIX_MAX + name);
            }
        }

        profile.getChildList().forEach(pair -> removeRedundantMinMaxMetrics(pair.first));
    }
@Test
    public void testRemoveRedundantMinMaxMetrics() {
        RuntimeProfile profile0 = new RuntimeProfile("profile0");
        RuntimeProfile profile1 = new RuntimeProfile("profile1");
        profile0.addChild(profile1);

        Counter time1 = profile1.addCounter("time1", TUnit.TIME_NS, null);
        time1.setValue(1500000000L);
        Counter minOfTime1 = profile1.addCounter("__MIN_OF_time1", TUnit.TIME_NS, null, "time1");
        minOfTime1.setValue(1500000000L);
        Counter maxOfTime1 = profile1.addCounter("__MAX_OF_time1", TUnit.TIME_NS, null, "time1");
        maxOfTime1.setValue(1500000000L);

        Counter time2 = profile1.addCounter("time2", TUnit.TIME_NS, null);
        time2.setValue(2000000000L);
        Counter minOfTime2 = profile1.addCounter("__MIN_OF_time2", TUnit.TIME_NS, null, "time2");
        minOfTime2.setValue(1500000000L);
        Counter maxOfTime2 = profile1.addCounter("__MAX_OF_time2", TUnit.TIME_NS, null, "time2");
        maxOfTime2.setValue(3000000000L);

        Counter count1 = profile1.addCounter("count1", TUnit.UNIT, null);
        count1.setValue(6);
        Counter minOfCount1 = profile1.addCounter("__MIN_OF_count1", TUnit.UNIT, null, "count1");
        minOfCount1.setValue(1);
        Counter maxOfCount1 = profile1.addCounter("__MAX_OF_count1", TUnit.UNIT, null, "count1");
        maxOfCount1.setValue(1);

        Counter count2 = profile1.addCounter("count2", TUnit.UNIT, null);
        count2.setValue(6);
        Counter minOfCount2 = profile1.addCounter("__MIN_OF_count2", TUnit.UNIT, null, "count2");
        minOfCount2.setValue(1);
        Counter maxOfCount2 = profile1.addCounter("__MAX_OF_count2", TUnit.UNIT, null, "count2");
        maxOfCount2.setValue(3);

        RuntimeProfile.removeRedundantMinMaxMetrics(profile0);

        Assert.assertNull(profile1.getCounter("__MIN_OF_time1"));
        Assert.assertNull(profile1.getCounter("__MAX_OF_time1"));
        Assert.assertNotNull(profile1.getCounter("__MIN_OF_time2"));
        Assert.assertNotNull(profile1.getCounter("__MAX_OF_time2"));
        Assert.assertNotNull(profile1.getCounter("__MIN_OF_count1"));
        Assert.assertNotNull(profile1.getCounter("__MAX_OF_count1"));
        Assert.assertNotNull(profile1.getCounter("__MIN_OF_count2"));
        Assert.assertNotNull(profile1.getCounter("__MAX_OF_count2"));
    }