org.agrona.concurrent.NoOpIdleStrategy Java Examples

The following examples show how to use org.agrona.concurrent.NoOpIdleStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BenchmarkConfiguration.java    From artio with Apache License 2.0 6 votes vote down vote up
static IdleStrategy idleStrategy()
{
    final String strategyName = System.getProperty("fix.benchmark.engine_idle", "");
    switch (strategyName)
    {
        case "noop":
            return new NoOpIdleStrategy();

        case "yield":
            return new YieldingIdleStrategy();

        default:
        case "backoff":
            return backoffIdleStrategy();
    }
}
 
Example #2
Source File: ConfigurationTest.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
@Test
void defaultOptions()
{
    final Configuration configuration = new Builder()
        .numberOfMessages(123)
        .messageTransceiverClass(InMemoryMessageTransceiver.class)
        .outputFileNamePrefix("defaults")
        .systemProperties(new Properties())
        .build();

    assertEquals(123, configuration.numberOfMessages());
    assertEquals(DEFAULT_WARM_UP_ITERATIONS, configuration.warmUpIterations());
    assertEquals(DEFAULT_ITERATIONS, configuration.iterations());
    assertEquals(DEFAULT_BATCH_SIZE, configuration.batchSize());
    assertEquals(MIN_MESSAGE_LENGTH, configuration.messageLength());
    assertSame(InMemoryMessageTransceiver.class, configuration.messageTransceiverClass());
    assertSame(NoOpIdleStrategy.INSTANCE, configuration.sendIdleStrategy());
    assertSame(NoOpIdleStrategy.INSTANCE, configuration.receiveIdleStrategy());
    assertEquals(Paths.get("results").toAbsolutePath(), configuration.outputDirectory());
    assertEquals("defaults_123_" + DEFAULT_BATCH_SIZE + "_" + MIN_MESSAGE_LENGTH +
        "_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        configuration.outputFileNamePrefix());
}
 
Example #3
Source File: ConfigurationTest.java    From benchmarks with Apache License 2.0 6 votes vote down vote up
@Test
void fromSystemPropertiesDefaults()
{
    setProperty(OUTPUT_FILE_NAME_PREFIX_PROP_NAME, "test-out-prefix");
    setProperty(MESSAGES_PROP_NAME, "42");
    setProperty(MESSAGE_TRANSCEIVER_PROP_NAME, InMemoryMessageTransceiver.class.getName());

    final Configuration configuration = fromSystemProperties();

    assertEquals(42, configuration.numberOfMessages());
    assertEquals(DEFAULT_WARM_UP_ITERATIONS, configuration.warmUpIterations());
    assertEquals(DEFAULT_ITERATIONS, configuration.iterations());
    assertEquals(DEFAULT_BATCH_SIZE, configuration.batchSize());
    assertEquals(MIN_MESSAGE_LENGTH, configuration.messageLength());
    assertSame(InMemoryMessageTransceiver.class, configuration.messageTransceiverClass());
    assertSame(NoOpIdleStrategy.INSTANCE, configuration.sendIdleStrategy());
    assertSame(NoOpIdleStrategy.INSTANCE, configuration.receiveIdleStrategy());
    assertEquals(Paths.get("results").toAbsolutePath(), configuration.outputDirectory());
}
 
Example #4
Source File: LowLatencyMediaDriver.java    From aeron with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args)
{
    loadPropertiesFiles(args);

    final MediaDriver.Context ctx = new MediaDriver.Context()
        .termBufferSparseFile(false)
        .useWindowsHighResTimer(true)
        .threadingMode(ThreadingMode.DEDICATED)
        .conductorIdleStrategy(BusySpinIdleStrategy.INSTANCE)
        .receiverIdleStrategy(NoOpIdleStrategy.INSTANCE)
        .senderIdleStrategy(NoOpIdleStrategy.INSTANCE);

    try (MediaDriver ignored = MediaDriver.launch(ctx))
    {
        new ShutdownSignalBarrier().await();

        System.out.println("Shutdown Driver...");
    }
}
 
Example #5
Source File: ReplayIndexTest.java    From artio with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp()
{
    mediaDriver = TestFixtures.launchMediaDriver();
    aeronArchive = AeronArchive.connect();

    recordingIdLookup = new RecordingIdLookup(new YieldingIdleStrategy(), aeron().countersReader());

    aeronArchive.startRecording(CHANNEL, STREAM_ID, SourceLocation.LOCAL);

    final Aeron aeron = aeron();
    publication = aeron.addExclusivePublication(CHANNEL, STREAM_ID);
    subscription = aeron.addSubscription(CHANNEL, STREAM_ID);

    IoUtil.deleteIfExists(logFile(SESSION_ID));
    IoUtil.deleteIfExists(logFile(SESSION_ID_2));

    newReplayIndex();
    query = new ReplayQuery(
        DEFAULT_LOG_FILE_DIR,
        DEFAULT_LOGGER_CACHE_NUM_SETS,
        DEFAULT_LOGGER_CACHE_SET_SIZE,
        existingBufferFactory,
        DEFAULT_OUTBOUND_LIBRARY_STREAM,
        new NoOpIdleStrategy(),
        aeronArchive,
        errorHandler,
        DEFAULT_ARCHIVE_REPLAY_STREAM);
}
 
Example #6
Source File: ConfigurationTest.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Test
void explicitOptions(final @TempDir Path tempDir)
{
    final Path outputDirectory = tempDir.resolve("my-output-dir");
    final Configuration configuration = new Builder()
        .warmUpIterations(3)
        .iterations(11)
        .numberOfMessages(666)
        .batchSize(4)
        .messageLength(119)
        .messageTransceiverClass(InMemoryMessageTransceiver.class)
        .sendIdleStrategy(NoOpIdleStrategy.INSTANCE)
        .receiveIdleStrategy(YieldingIdleStrategy.INSTANCE)
        .outputDirectory(outputDirectory)
        .outputFileNamePrefix("explicit-opts")
        .build();

    assertEquals(3, configuration.warmUpIterations());
    assertEquals(11, configuration.iterations());
    assertEquals(666, configuration.numberOfMessages());
    assertEquals(4, configuration.batchSize());
    assertEquals(119, configuration.messageLength());
    assertSame(InMemoryMessageTransceiver.class, configuration.messageTransceiverClass());
    assertSame(NoOpIdleStrategy.INSTANCE, configuration.sendIdleStrategy());
    assertSame(YieldingIdleStrategy.INSTANCE, configuration.receiveIdleStrategy());
    assertEquals(outputDirectory.toAbsolutePath(), configuration.outputDirectory());
    assertTrue(configuration.outputFileNamePrefix().startsWith("explicit-opts"));
}
 
Example #7
Source File: ConfigurationTest.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Test
void toStringPrintsConfiguredValues()
{
    final Configuration configuration = new Builder()
        .warmUpIterations(4)
        .iterations(10)
        .numberOfMessages(777)
        .batchSize(2)
        .messageLength(64)
        .messageTransceiverClass(InMemoryMessageTransceiver.class)
        .sendIdleStrategy(NoOpIdleStrategy.INSTANCE)
        .receiveIdleStrategy(YieldingIdleStrategy.INSTANCE)
        .outputFileNamePrefix("my-file")
        .systemProperties(props("java", "25"))
        .build();

    assertEquals("Configuration{" +
        "\n    warmUpIterations=4" +
        "\n    iterations=10" +
        "\n    numberOfMessages=777" +
        "\n    batchSize=2" +
        "\n    messageLength=64" +
        "\n    messageTransceiverClass=uk.co.real_logic.benchmarks.remote.InMemoryMessageTransceiver" +
        "\n    sendIdleStrategy=NoOpIdleStrategy{alias=noop}" +
        "\n    receiveIdleStrategy=YieldingIdleStrategy{alias=yield}" +
        "\n    outputDirectory=" + Paths.get("results").toAbsolutePath() +
        "\n    outputFileNamePrefix=my-file_777_2_64" +
        "_73ccec448ba12264acb12e7f9f36fddc73e8c62e43549b786a901c88891610c9" +
        "\n}",
        configuration.toString());
}