Last active
July 4, 2022 12:44
-
-
Save viliam-durina/3f4996c2d5a7b93cae86cde16d5889b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.hazelcast.sql; | |
import com.hazelcast.core.HazelcastInstance; | |
import com.hazelcast.jet.sql.SqlTestSupport; | |
import org.junit.Test; | |
import java.io.Serializable; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
import static java.util.concurrent.TimeUnit.NANOSECONDS; | |
// foo | |
public class FooTest extends SqlTestSupport { | |
@Test | |
public void test() throws Exception { | |
HazelcastInstance inst = createHazelcastInstance(); | |
createHazelcastInstance(); | |
createMapping(inst, "m", Integer.class, C.class); | |
for (int i = 0; i < 500; i++) { | |
inst.getMap("m").put(i, new C()); | |
} | |
bench(inst, "select *", "select * from m"); | |
bench(inst, "select 60 fields", "select " + fieldList(60) + " from m"); | |
bench(inst, "select 140 fields", "select " + fieldList(140) + " from m"); | |
} | |
private String fieldList(int numFields) { | |
return IntStream.range(0, numFields) | |
.mapToObj(i -> "i" + i) | |
.collect(Collectors.joining(", ")); | |
} | |
private void bench(HazelcastInstance inst, String name, String query) { | |
for (int i = 0; i < 5; i++) { | |
long start = System.nanoTime(); | |
SqlResult res = inst.getSql().execute(query); | |
res.iterator().forEachRemaining(row -> {}); | |
System.out.println(name + ": iteration " + i + " took " + NANOSECONDS.toMillis(System.nanoTime() - start) + " ms"); | |
} | |
} | |
public static class C implements Serializable { | |
public int i0, i1, i2, i3, i4, i5, i6, i7, i8, i9; | |
public int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19; | |
public int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29; | |
public int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39; | |
public int i40, i41, i42, i43, i44, i45, i46, i47, i48, i49; | |
public int i50, i51, i52, i53, i54, i55, i56, i57, i58, i59; | |
public int i60, i61, i62, i63, i64, i65, i66, i67, i68, i69; | |
public int i70, i71, i72, i73, i74, i75, i76, i77, i78, i79; | |
public int i80, i81, i82, i83, i84, i85, i86, i87, i88, i89; | |
public int i90, i91, i92, i93, i94, i95, i96, i97, i98, i99; | |
public int i100, i101, i102, i103, i104, i105, i106, i107, i108, i109; | |
public int i110, i111, i112, i113, i114, i115, i116, i117, i118, i119; | |
public int i120, i121, i122, i123, i124, i125, i126, i127, i128, i129; | |
public int i130, i131, i132, i133, i134, i135, i136, i137, i138, i139; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment