Search in sources :

Example 1 with OpenHashStringMap

use of org.apache.logging.log4j.perf.nogc.OpenHashStringMap in project logging-log4j2 by apache.

the class ThreadContextBenchmark method setup.

@Setup
public void setup() {
    System.setProperty("log4j2.threadContextMap", IMPLEMENTATIONS.get(threadContextMapAlias).getName());
    ThreadContextBenchmarkAccess.init();
    injector = ContextDataInjectorFactory.createInjector();
    System.out.println(threadContextMapAlias + ": Injector = " + injector);
    reusableContextData = threadContextMapAlias.contains("Array") ? new SortedArrayStringMap() : new OpenHashStringMap<>();
    keys = new String[count];
    values = new String[count];
    final Random r = new Random();
    for (int j = 0; j < keys.length; j++) {
        final char[] str = new char[KEY_LENGTH];
        for (int i = 0; i < str.length; i++) {
            str[i] = (char) r.nextInt();
        }
        keys[j] = new String(str);
        values[j] = new String(str);
    }
    // count
    final int PROPERTIES_COUNT = 5;
    propertyList = new ArrayList<>(PROPERTIES_COUNT);
    for (int j = 0; j < PROPERTIES_COUNT; j++) {
        final char[] str = new char[KEY_LENGTH];
        for (int i = 0; i < str.length; i++) {
            str[i] = (char) r.nextInt();
        }
        propertyList.add(Property.createProperty(new String(str), new String(str)));
    }
    // ensure ThreadContext contains values
    clearAndPut();
}
Also used : Random(java.util.Random) SortedArrayStringMap(org.apache.logging.log4j.util.SortedArrayStringMap) OpenHashStringMap(org.apache.logging.log4j.perf.nogc.OpenHashStringMap) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

Random (java.util.Random)1 OpenHashStringMap (org.apache.logging.log4j.perf.nogc.OpenHashStringMap)1 SortedArrayStringMap (org.apache.logging.log4j.util.SortedArrayStringMap)1 Setup (org.openjdk.jmh.annotations.Setup)1