<commit_before>/*
 * Copyright 2014 <NAME>
 *
 * Licensed 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 io.rainfall.jcache;

import io.rainfall.generator.ByteArrayGenerator;
import org.ehcache.jcache.JCacheConfiguration;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import io.rainfall.Runner;
import io.rainfall.Scenario;
import io.rainfall.SyntaxException;
import io.rainfall.configuration.ConcurrencyConfig;
import io.rainfall.configuration.ReportingConfig;
import io.rainfall.generator.StringGenerator;
import io.rainfall.jcache.statistics.JCacheResult;
import io.rainfall.utils.SystemTest;

import java.util.concurrent.TimeUnit;

import javax.cache.Cache;
import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.Duration;
import javax.cache.expiry.ModifiedExpiryPolicy;

import static io.rainfall.configuration.ReportingConfig.*;
import static java.util.concurrent.TimeUnit.MINUTES;
import static io.rainfall.execution.Executions.nothingFor;
import static io.rainfall.execution.Executions.times;
import static io.rainfall.jcache.JCacheOperations.get;
import static io.rainfall.jcache.JCacheOperations.put;
import static io.rainfall.jcache.JCacheOperations.remove;
import static io.rainfall.unit.TimeDivision.seconds;

/**
 * @author <NAME>
 */

@Category(SystemTest.class)
public class CrudTest {

  @Test
  public void testLoad() throws SyntaxException {
    Cache one = Caching.getCachingProvider().getCacheManager().createCache("testSimpleLoad",
        new JCacheConfiguration<String, Byte>(new MutableConfiguration<String, Byte>().setStatisticsEnabled(true)
            .setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 10)))
            .setStoreByValue(true)));

    CacheConfig<String, byte[]> cacheConfig = CacheConfig.<String, byte[]>cacheConfig()
        .caches(one)
        .using(StringGenerator.fixedLength(10), ByteArrayGenerator.fixedLength(128))
        .sequentially();
    ConcurrencyConfig concurrency = ConcurrencyConfig.concurrencyConfig()
        .threads(4).timeout(5, MINUTES);
    ReportingConfig reporting = reportingConfig(JCacheResult.class, text(), html());

    Scenario scenario = Scenario.scenario("Cache load")
        .exec(put().withWeight(0.10))
        .exec(get().withWeight(0.80))
        .exec(remove().withWeight(0.10));

    Runner.setUp(scenario)
        .executed(times(10000000), nothingFor(10, seconds))
        .config(cacheConfig, concurrency, reporting)
//          .assertion(latencyTime(), isLessThan(1, seconds))
        .start();
  }

}
<commit_msg>return final stats at the end of the run<commit_after>/*
 * Copyright 2014 <NAME>
 *
 * Licensed 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 io.rainfall.jcache;

import io.rainfall.generator.ByteArrayGenerator;
import org.ehcache.jcache.JCacheConfiguration;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import io.rainfall.Runner;
import io.rainfall.Scenario;
import io.rainfall.SyntaxException;
import io.rainfall.configuration.ConcurrencyConfig;
import io.rainfall.configuration.ReportingConfig;
import io.rainfall.generator.StringGenerator;
import io.rainfall.jcache.statistics.JCacheResult;
import io.rainfall.statistics.StatisticsPeekHolder;
import io.rainfall.utils.SystemTest;

import java.util.concurrent.TimeUnit;

import javax.cache.Cache;
import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.Duration;
import javax.cache.expiry.ModifiedExpiryPolicy;

import static io.rainfall.configuration.ReportingConfig.*;
import static java.util.concurrent.TimeUnit.MINUTES;
import static io.rainfall.execution.Executions.nothingFor;
import static io.rainfall.execution.Executions.times;
import static io.rainfall.jcache.JCacheOperations.get;
import static io.rainfall.jcache.JCacheOperations.put;
import static io.rainfall.jcache.JCacheOperations.remove;
import static io.rainfall.unit.TimeDivision.seconds;

/**
 * @author <NAME>
 */

@Category(SystemTest.class)
public class CrudTest {

  @Test
  public void testLoad() throws SyntaxException {
    Cache one = Caching.getCachingProvider().getCacheManager().createCache("testSimpleLoad",
        new JCacheConfiguration<String, Byte>(new MutableConfiguration<String, Byte>().setStatisticsEnabled(true)
            .setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 10)))
            .setStoreByValue(true)));

    CacheConfig<String, byte[]> cacheConfig = CacheConfig.<String, byte[]>cacheConfig()
        .caches(one)
        .using(StringGenerator.fixedLength(10), ByteArrayGenerator.fixedLength(128))
        .sequentially();
    ConcurrencyConfig concurrency = ConcurrencyConfig.concurrencyConfig()
        .threads(4).timeout(5, MINUTES);
    ReportingConfig reporting = reportingConfig(JCacheResult.class, text(), html());

    Scenario scenario = Scenario.scenario("Cache load")
        .exec(put().withWeight(0.10))
        .exec(get().withWeight(0.80))
        .exec(remove().withWeight(0.10));

    StatisticsPeekHolder finalStats = Runner.setUp(scenario)
        .executed(times(10000000), nothingFor(10, seconds))
        .config(cacheConfig, concurrency, reporting)
//          .assertion(latencyTime(), isLessThan(1, seconds))
        .start();
  }

}

{'fraction_non_alphanumeric': 0.10665622552858262, 'fraction_numerical': 0.01158966327329679, 'mean_word_length': 4.706881143878463, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2227497', 'n_tokens_mistral': 1884, 'n_tokens_neox': 1791, 'n_words': 422}