Skip to content

Instantly share code, notes, and snippets.

@markrofail
Created May 16, 2018 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markrofail/174ed370a2f2ac24800fde2fc27e2d38 to your computer and use it in GitHub Desktop.
Save markrofail/174ed370a2f2ac24800fde2fc27e2d38 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.*;
public class test {
public static int randomNum(int range, int offset) {
return (int) Math.floor(Math.random() * range) + offset;
}
public static Writer initLogger(String s) {
try {
File dir = new File(s + ".txt");
FileOutputStream is = new FileOutputStream(dir);
OutputStreamWriter osw = new OutputStreamWriter(is);
return new BufferedWriter(osw);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
int[] row = { 1, 2, 3, 4, 5 };
for (int k = 1; k <= 3; k++) {
Writer w1 = null;
int oldLimit = (int) Math.pow(10, k - 1);
int limit = (int) Math.pow(10, k);
for (int i = oldLimit; i <= limit; i++) {
w1 = initLogger("inserts - " + limit);
String fktest = "{";
int num = randomNum(5, 1);
fktest += row[randomNum(5, 0)] + "";
num--;
for (int j = 0; j < num; j++) {
fktest += ",";
fktest += row[randomNum(5, 0)] + "";
}
fktest += "}";
try {
w1.write("INSERT INTO FKTABLEFORARRAYPERFORMANCE VALUES ('" + fktest + "', " + i + ");\n");
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(i);
try {
w1.flush();
w1.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment