Created
June 13, 2016 14:51
-
-
Save tanner0101/dc1bb49649a91f35ee5eea4720a6401d to your computer and use it in GitHub Desktop.
Spring Benchmark
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
package com.hlprmnky.vapor_spring_benchmark; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.concurrent.atomic.AtomicLong; | |
import com.google.common.collect.ImmutableMap; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestParam; | |
import org.springframework.web.bind.annotation.RestController; | |
@RestController | |
public class ApplicationController { | |
private final AtomicLong counter = new AtomicLong(); | |
private final Random random = new Random(); | |
@Autowired | |
private UserRepository userRepository; | |
@RequestMapping("/json") | |
public Json json() { | |
return new Json(counter.incrementAndGet(), Arrays.asList(1, 2, 3), | |
ImmutableMap.of("one", 1, "two", 2, "three", 3), | |
"test", 42, 3.14); | |
} | |
@RequestMapping("/plaintext") | |
public String plaintext() { | |
return "Hello, World!"; | |
} | |
@RequestMapping("/sqlite-fetch") | |
public User sqliteFetch() { | |
List<User> allUsers = userRepository.findAll(); | |
return allUsers.get(random.nextInt(allUsers.size())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment