# Feeder execution time is included in the scenario duration

**URL:** <https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252>\
**Category:** Gatling (Open-Source)\
**Created:** [April 30, 2015, 3:17pm UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252 "2015-04-30T15:17:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nat\_M](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nat\_M](https://community.gatling.io/u/Nat_M)\
**Post date:** [April 30, 2015, 3:17pm UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252/1 "2015-04-30T15:17:34Z")

</div>

Hello,

we have implemented custom Feeder which loads the data from Solr dynamically using Solr’s REST API before the main test (which stresses another API under test ) is being run.

This is happening as part of the scenario, e.g. every time the test is run the test data is being loaded from Solr into memory first.

It is quite a lengthy process - it takes 6 min to load the data. Let’s say the duration is set to 1 min. Gatling reports on the duration of the entire 7 min test run and not just 1 min for which we are interested to see the stats.

Can this behaviour be changed so that the time it takes feeder to load the data is not included in the test run. The reporting metrics are inaccurate as a result.

Natalie

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 30, 2015, 3:38pm UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252/2 "2015-04-30T15:38:41Z")

</div>

Hi,

Where do you run this code? In a before block?

---

<div class="post-metadata">

**Author:** ![Nat\_M](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nat\_M](https://community.gatling.io/u/Nat_M)\
**Post date:** [April 30, 2015, 4:32pm UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252/3 "2015-04-30T16:32:10Z")

</div>

In the scenario itself. I am not aware about before block

Here is an example:

val scenario1 = scenario(“my scenario”)  
.feed(data\_1)  
.during(duration) {  
exec(http(TRANSACTION\_1)  
.get(URL)  
check(jsonPath(PROG).exists)  
)  
.pause(1)  
.feed(data\_1)  
}

---

<div class="post-metadata">

**Author:** ![aidy\_lewis](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@aidy\_lewis](https://community.gatling.io/u/aidy_lewis)\
**Post date:** [April 30, 2015, 5:12pm UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252/4 "2015-04-30T17:12:23Z")

</div>

The Gatling hooks are not included in the response times.  
[http://gatling.io/docs/2.1.5/general/simulation\_structure.html#hooks](http://gatling.io/docs/2.1.5/general/simulation_structure.html#hooks)

---

<div class="post-metadata">

**Author:** ![Nat\_M](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nat\_M](https://community.gatling.io/u/Nat_M)\
**Post date:** [May 1, 2015, 2:08pm UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252/5 "2015-05-01T14:08:10Z")

</div>

Thanks, sounds like this is might be a solution however the documentation says you can only put scala code in this block, not Gatling DSL.

Can I separate Feeder block in there? Has anyone got any working example they can post here, would be much appreciated.

Nat

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [May 3, 2015, 8:04am UTC](https://community.gatling.io/t/feeder-execution-time-is-included-in-the-scenario-duration/2252/6 "2015-05-03T08:04:00Z")

</div>

Indeed, you can only execute custom code in before and after hooks, not run Gatling DSL.  
If you want to perform HTTP requests in there, you can use [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client) (the HTTP client Gatling uses underneath) or even UrlConnection.
