merlimat commented on a change in pull request #9769: URL: https://github.com/apache/pulsar/pull/9769#discussion_r585146908
########## File path: pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java ########## @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.testclient; + +import com.google.common.collect.ImmutableSet; +import io.netty.util.internal.PlatformDependent; +import lombok.experimental.UtilityClass; +import org.slf4j.Logger; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.Collection; + +/** + * Utility for test clients + */ +@UtilityClass +public class PerfClientUtils { + + private static final Collection<String> USELESS_PROPERTIES = ImmutableSet + .<String>builder() + .add("java.class.path") + .build(); + /** + * Print useful JVM information, you need this information in order to be able + * to compare the results of executions in different environments. + * @param log + */ + public static void printJVMInformation(Logger log) { + RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); + log.info("Java Runtime Info"); + System.getProperties().forEach( (k,v)-> { + String key = k.toString(); + if (!USELESS_PROPERTIES.contains(key) + && (key.startsWith("java.") || key.startsWith("os."))) { + log.info("{} = {}", key, v); + } + }); + log.info("JVM args {}", runtimeMXBean.getInputArguments()); + log.info("Netty max memory (PlatformDependent.maxDirectMemory()) {}", PlatformDependent.maxDirectMemory()); Review comment: Can we convert it to GB to make it easier to read? ########## File path: pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java ########## @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.testclient; + +import com.google.common.collect.ImmutableSet; +import io.netty.util.internal.PlatformDependent; +import lombok.experimental.UtilityClass; +import org.slf4j.Logger; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.Collection; + +/** + * Utility for test clients + */ +@UtilityClass +public class PerfClientUtils { + + private static final Collection<String> USELESS_PROPERTIES = ImmutableSet + .<String>builder() + .add("java.class.path") + .build(); + /** + * Print useful JVM information, you need this information in order to be able + * to compare the results of executions in different environments. + * @param log + */ + public static void printJVMInformation(Logger log) { + RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); + log.info("Java Runtime Info"); + System.getProperties().forEach( (k,v)-> { Review comment: I've been annoyed by ZK printing this (and classpath) for many years! :( Can we keep it at just the args and the memory size? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
