// Path: src/main/java/org/apache/flink/benchmark/functions/IntLongApplications.java
// public class IntLongApplications {
//     public static <W extends Window> void reduceWithWindow(
//             DataStreamSource<IntegerLongSource.Record> source,
//             WindowAssigner<Object, W> windowAssigner) {
//         source
//                 .map(new MultiplyIntLongByTwo())
//                 .keyBy(record -> record.key)
//                 .window(windowAssigner)
//                 .reduce(new SumReduceIntLong())
//                 .addSink(new CollectSink());
//     }
// }
// 
// Path: src/main/java/org/apache/flink/benchmark/functions/IntegerLongSource.java
// public class IntegerLongSource extends RichParallelSourceFunction<IntegerLongSource.Record> {
//     public static final class Record {
//         public final int key;
//         public final long value;
// 
//         public Record() {
//             this(0, 0);
//         }
// 
//         public Record(int key, long value) {
//             this.key = key;
//             this.value = value;
//         }
// 
//         public static Record of(int key, long value) {
//             return new Record(key, value);
//         }
// 
//         public int getKey() {
//             return key;
//         }
// 
//         @Override
//         public String toString() {
//             return String.format("(%s, %s)", key, value);
//         }
//     }
// 
//     private volatile boolean running = true;
//     private int numberOfKeys;
//     private long numberOfElements;
// 
//     public IntegerLongSource(int numberOfKeys, long numberOfElements) {
//         this.numberOfKeys = numberOfKeys;
//         this.numberOfElements = numberOfElements;
//     }
// 
//     @Override
//     public void run(SourceContext<Record> ctx) throws Exception {
//         long counter = 0;
// 
//         while (running && counter < numberOfElements) {
//             synchronized (ctx.getCheckpointLock()) {
//                 ctx.collectWithTimestamp(Record.of((int) (counter % numberOfKeys), counter), counter);
//                 counter++;
//             }
//         }
//         running = false;
//     }
// 
//     @Override
//     public void cancel() {
//         running = false;
//     }
// }


import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.VerboseMode;
import java.io.IOException;
import org.apache.flink.benchmark.functions.IntLongApplications;
import org.apache.flink.benchmark.functions.IntegerLongSource;
import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows;
import org.apache.flink.streaming.api.windowing.assigners.GlobalWindows;
import org.apache.flink.streaming.api.windowing.assigners.SlidingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.OperationsPerInvocation;
/*
 * 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.flink.benchmark;




@OperationsPerInvocation(value = WindowBenchmarks.RECORDS_PER_INVOCATION)
public class WindowBenchmarks extends BenchmarkBase {

	public static final int RECORDS_PER_INVOCATION = 7_000_000;

	public static void main(String[] args)
			throws RunnerException {
// Path: src/main/java/org/apache/flink/benchmark/functions/IntLongApplications.java
// public class IntLongApplications {
//     public static <W extends Window> void reduceWithWindow(
//             DataStreamSource<IntegerLongSource.Record> source,
//             WindowAssigner<Object, W> windowAssigner) {
//         source
//                 .map(new MultiplyIntLongByTwo())
//                 .keyBy(record -> record.key)
//                 .window(windowAssigner)
//                 .reduce(new SumReduceIntLong())
//                 .addSink(new CollectSink());
//     }
// }
// 
// Path: src/main/java/org/apache/flink/benchmark/functions/IntegerLongSource.java
// public class IntegerLongSource extends RichParallelSourceFunction<IntegerLongSource.Record> {
//     public static final class Record {
//         public final int key;
//         public final long value;
// 
//         public Record() {
//             this(0, 0);
//         }
// 
//         public Record(int key, long value) {
//             this.key = key;
//             this.value = value;
//         }
// 
//         public static Record of(int key, long value) {
//             return new Record(key, value);
//         }
// 
//         public int getKey() {
//             return key;
//         }
// 
//         @Override
//         public String toString() {
//             return String.format("(%s, %s)", key, value);
//         }
//     }
// 
//     private volatile boolean running = true;
//     private int numberOfKeys;
//     private long numberOfElements;
// 
//     public IntegerLongSource(int numberOfKeys, long numberOfElements) {
//         this.numberOfKeys = numberOfKeys;
//         this.numberOfElements = numberOfElements;
//     }
// 
//     @Override
//     public void run(SourceContext<Record> ctx) throws Exception {
//         long counter = 0;
// 
//         while (running && counter < numberOfElements) {
//             synchronized (ctx.getCheckpointLock()) {
//                 ctx.collectWithTimestamp(Record.of((int) (counter % numberOfKeys), counter), counter);
//                 counter++;
//             }
//         }
//         running = false;
//     }
// 
//     @Override
//     public void cancel() {
//         running = false;
//     }
// }


// Path: src/main/java/org/apache/flink/benchmark/WindowBenchmarks.java
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.VerboseMode;
import java.io.IOException;
import org.apache.flink.benchmark.functions.IntLongApplications;
import org.apache.flink.benchmark.functions.IntegerLongSource;
import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.windowing.assigners.EventTimeSessionWindows;
import org.apache.flink.streaming.api.windowing.assigners.GlobalWindows;
import org.apache.flink.streaming.api.windowing.assigners.SlidingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.OperationsPerInvocation;

/*
 * 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.flink.benchmark;




@OperationsPerInvocation(value = WindowBenchmarks.RECORDS_PER_INVOCATION)
public class WindowBenchmarks extends BenchmarkBase {

	public static final int RECORDS_PER_INVOCATION = 7_000_000;

	public static void main(String[] args)
			throws RunnerException {
		Options options = new OptionsBuilder()