Skip to content

Instantly share code, notes, and snippets.

@ybonnel
Created January 16, 2013 07:09
Show Gist options
  • Save ybonnel/4545230 to your computer and use it in GitHub Desktop.
Save ybonnel/4545230 to your computer and use it in GitHub Desktop.
Generateur jajascript
@Test
@Ignore
public void should_be_very_very_fast() throws IOException, SAXException {
int max = 250;
Random random = new Random();
ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
WebConversation wc = new WebConversation();
for (int i =0; i < max; i++) {
List<Commande> commandes = new ArrayList<Commande>();
for (int j = 1; j <= (i+1)*5; j++) {
Commande commande = new Commande();
commande.setNomVol(Integer.toBinaryString(j));
commande.setHeureDepart(j);
commande.setTempsVol(random.nextInt(10) + 1);
commande.setPrix(random.nextInt(20) + 1);
commandes.add(commande);
}
String request = mapper.writeValueAsString(commandes);
PostMethodWebRequest postRequest = new PostMethodWebRequest(getURL() + "jajascript/optimize",
new ByteArrayInputStream(request.getBytes()), "application/json");
long startTime = System.nanoTime();
WebResponse response = wc.getResponse(postRequest);
long elapsedTime = System.nanoTime() - startTime;
assertEquals(200, response.getResponseCode());
assertEquals("application/json", response.getContentType());
System.out.println("Level " + (i+1) + " : " + elapsedTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment