adding think time in jmh
Sarath Babu
sarath.chalasani46 at gmail.com
Wed Jun 2 08:37:04 UTC 2021
Hi Team,
Does anyone have any ideas or thoughts on this.
Thanks,
Sarathabu C
On Wed, Jun 2, 2021 at 12:26 PM Sarath Babu <sarath.chalasani46 at gmail.com>
wrote:
> Thanks for your Quick response.
> I want to give *think time* between each thread request in below test
> case, Is there any option ?
>
> @SuppressWarnings("unchecked")
>
> @Benchmark
>
> @BenchmarkMode({ Mode.*SampleTime* })
>
> @OutputTimeUnit(TimeUnit.*MILLISECONDS*)
>
> @Warmup(iterations = 3)
>
> @Measurement(iterations = 10)
>
> @Threads(value = 50)
>
> *public* *void* measureCacheUpdateWithEagerConfig(EagerCachePut cPut,
> RandomNumberBelowThousand rNum) *throws* InterruptedException {
>
> cPut.cache.put(rNum.key, AccountUtil.*accountUpdate*(rNum.key));
>
> }
>
>
> @State(Scope.*Benchmark*)
>
> *public* *static* *class* EagerCachePut {
>
>
> *public* CacheManagerImpl impl;
>
> @SuppressWarnings("rawtypes")
>
> *public* Cache cache;
>
>
> @Setup
>
> *public* *void* setup() {
>
> impl = *new* CacheManagerImpl();
>
> cache = impl.getCache("lowUnitsAccountEagerDistributedCache");
>
> cachePutAccountObjects();
>
> }
>
>
> @SuppressWarnings("unchecked")
>
> *public* *void* cachePutAccountObjects() {
>
> *for* (*long* i = 1; i <= 1000; i++) {
>
> cache.put(i, AccountUtil.*getAccount*(i));
>
> }
>
> }
>
>
> @TearDown
>
> *public* *void* doTearDown() {
>
> impl = *null*;
>
> cache = *null*;
>
> }
>
> }
>
>
>
>
> @State(Scope.*Thread*)
>
> *public* *static* *class* RandomNumberBelowThousand {
>
>
> *public* *long* key;
>
>
> @Setup(Level.*Invocation*)
>
> *public* *void* doSetup() {
>
> key = getRandomNumber();
>
> }
>
>
> @TearDown(Level.*Invocation*)
>
> *public* *void* doTearDown() {
>
> key=0;
>
> }
>
> *public* *long* getRandomNumber() {
>
> *return* (*long*) ((Math.*random*() * (1000 - 1)) + 1);
>
> }
>
> }
>
>
> Thanks,
> Sarath
>
> On Wed, Jun 2, 2021 at 12:10 PM Dawid Weiss <dawid.weiss at gmail.com> wrote:
>
>>
>> I agree a think time option is needed for everyone using JMH:
>>
>> System.out.println("Do you really understand micro-benchmarking and would
>> like to proceed?");
>> waitForConfirmation();
>>
>> :)
>>
>> If you mean warmup then warmupIterations should be your friend.
>>
>> D.
>>
>> On Wed, Jun 2, 2021 at 8:33 AM Sarath Babu <sarath.chalasani46 at gmail.com>
>> wrote:
>>
>>> Hi Team,
>>> Is there any way we can add think time in jmh? if yes can you please give
>>> me a syntax or example to add think time.
>>>
>>>
>>> *******************
>>> Thanks and Regards
>>> *C.Sarathbabu*
>>> *Cont No: 9652511597*
>>>
>>
>
More information about the jmh-dev
mailing list