Skip to content

Instantly share code, notes, and snippets.

@hyeonjae
Last active January 12, 2017 05:51
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 hyeonjae/447df8c07f555e7b33547e9e31f0c70f to your computer and use it in GitHub Desktop.
Save hyeonjae/447df8c07f555e7b33547e9e31f0c70f to your computer and use it in GitHub Desktop.
spring annotation method argument performance issue test
@Before
public void setup() throws Exception {
this.mockMvc = webAppContextSetup(this.wac).build();
// warm up
for (int i = 0; i < 3000; i++) {
this.mockMvc.perform(post("/")
.contentType(MediaType.APPLICATION_JSON)
.header("Dooray-App-Key", UUID.randomUUID().toString()))
.andExpect(status().isOk())
.andReturn();
}
}
@Test
public void simple() throws Exception {
StopWatch watch = new StopWatch();
watch.start();
for (int i = 0; i < 50000; i++) {
if (i%5000 == 0) {
watch.stop();
System.out.println(watch.getTotalTimeMillis());
watch.start();
}
this.mockMvc.perform(post("/")
.contentType(MediaType.APPLICATION_JSON)
.header("Dooray-App-Key", UUID.randomUUID().toString()))
.andExpect(status().isOk())
.andReturn();
}
watch.stop();
System.out.println(watch.getTotalTimeMillis());
}
@RestController
@RequestMapping("/")
public class HelloController {
@ModelAttribute("DoorayAppKey")
public String getDoorayAppKey(@RequestHeader("Dooray-App-Key") String doorayAppKey) {
return doorayAppKey;
}
@RequestMapping(method = RequestMethod.POST)
public String printAppKey(@ModelAttribute("DoorayAppKey") String doorayAppKey) {
return "{ \"doorayAppKey\": \"" + doorayAppKey + "\" }";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment