Last active
January 12, 2017 05:51
-
-
Save hyeonjae/447df8c07f555e7b33547e9e31f0c70f to your computer and use it in GitHub Desktop.
spring annotation method argument performance issue test
This file contains hidden or 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
@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()); | |
} |
This file contains hidden or 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
@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