<commit_before># JAX-RS Performance

Compares performance of per-request and singleton JAX-RS resource classes.

See [JAX-RS Resource Lifecycle Performance Impact][1].

This project includes 4 resource classes: 2 per-request scoped and 2 singletons. Two are just returning a query param.
In the other two resources we will inject the UriInfo via @Context. The context is specific to a particular request.
So on a request-scoped resource it can be injected at creation time. For a singleton resource this needs to be handled different
by maybe creating proxy objects. 

## Build

    mvn clean install
    docker build -t jax-rs-performance .
    docker run -it --rm --name jax-rs-performance -p 8080:8080 -p 9990:9990 jax-rs-performance
    mvn clean verify
    
The host and number of test iterations can be configured in the jmeter-maven-plugin settings of the pom.xml.

## Results

The tests were performed with Java 1.8.0_45, Wildfly 8.2.0.Final including RESTeasy 3.0.10.Final.
Every test was run with 5 Threads and repeated 500000 times. JBoss was restarted after every test.

| Test                      | Avg | Min | Max | Requests/Second | 
| ------------------------- | --: | --: | --: | --------------: |
| Per-Request               |   2 |   0 | 170 |            1970 |  
| Per-Request with @Context |   2 |   0 | 174 |            1999 |
| Singleton                 |   2 |   0 | 195 |            2000 |  
| Singleton with @Context   |   2 |   0 | 397 |            2022 |

The JVisualVM Screenshots can be found in [results/visualvm](results/visualvm).
    
 [1]: http://stackoverflow.com/questions/30409895/jax-rs-resource-lifecycle-performance-impact<commit_msg>doc update<commit_after># JAX-RS Performance

Compares performance of per-request and singleton JAX-RS resource classes.

See [JAX-RS Resource Lifecycle Performance Impact][1].

This project includes 4 resource classes: 2 per-request scoped and 2 singletons. Two are just returning a query param.
In the other two resources we will inject the UriInfo via @Context. The context is specific to a particular request.
So on a request-scoped resource it can be injected at creation time. For a singleton resource this needs to be handled different
by maybe creating proxy objects. 

## Build

    mvn clean install
    docker build -t jax-rs-performance .
    docker run -it --rm --name jax-rs-performance -p 8080:8080 -p 9990:9990 jax-rs-performance
    mvn clean verify
    
The host and number of test iterations can be configured in the jmeter-maven-plugin settings of the pom.xml.

## Results

The tests were performed with Java 1.8.0_45, Wildfly 8.2.0.Final including RESTeasy 3.0.10.Final.
Every test was executed with 5 Threads and repeated 500000 times. Wildfly was restarted after every test.

| Test                      | Avg | Min | Max | Requests/Second | 
| ------------------------- | --: | --: | --: | --------------: |
| Per-Request               |   2 |   0 | 170 |            1970 |  
| Per-Request with @Context |   2 |   0 | 174 |            1999 |
| Singleton                 |   2 |   0 | 195 |            2000 |  
| Singleton with @Context   |   2 |   0 | 397 |            2022 |

The JVisualVM Screenshots can be found in [results/visualvm](results/visualvm).
    
 [1]: http://stackoverflow.com/questions/30409895/jax-rs-resource-lifecycle-performance-impact
{'fraction_non_alphanumeric': 0.1030989272943981, 'fraction_numerical': 0.050059594755661505, 'mean_word_length': 2.3772635814889336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1808219', 'n_tokens_mistral': 1083, 'n_tokens_neox': 922, 'n_words': 384}