Rest Assured Vs. Apache HttpClient performance



  • I am checking Rest Assured now, and want to understand its performance. So, I created 2 unit tests:

    public static final String C_URL = "http://ergast.com/api/f1/2017/circuits.json";
    
    @Test
    public void test_getCircuitsFor2017Season_only() {
    
        System.out.println("test_getCircuitsFor2017Season_only");
    
        long time = System.currentTimeMillis();
        given().
        when().
        get(C_URL);
        System.out.println(System.currentTimeMillis() - time);
    
    }
    
    
    @Test
    public void test_apache4() {
    
        System.out.println("test_apache4");
    
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet(C_URL);
        try {
            long time = System.currentTimeMillis();
            CloseableHttpResponse response1 = httpclient.execute(httpGet);
            System.out.println(System.currentTimeMillis() - time);
    
        } catch (IOException e) {
            e.printStackTrace();
        }
    
    }
    

    And the results are:

    test_apache4
    223
    test_getCircuitsFor2017Season_only
    1027
    

    Is it a fair test? Can performance be improved for Rest Assured?

    Thanks!



  • According to this question Rest Assured is pretty slow on the first request you make. Looks like it has to warm up a little for some reason.

    I've tested version 4.0 of Rest Assured myself, and this appears to be the case. The first request is 2000ms+, then every subsequent request in the same suite is 200-300ms.

    A counter question might be: why compare them? Rest Assured is for testing API requests and is extremely rich in terms of features and ability. The HttpClient from apache is for making requests and comes with none of the testing features.

    If you are making requests in order to test them, use Rest Assured. If you're making requests as a means to an end, use HttpClient.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2