# Global requests per second calculation

**URL:** <https://community.gatling.io/t/global-requests-per-second-calculation/696>\
**Category:** Gatling (Open-Source)\
**Created:** [November 27, 2013, 5:20pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696 "2013-11-27T17:20:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ak\_Ak](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Ak\_Ak](https://community.gatling.io/u/Ak_Ak)\
**Post date:** [November 27, 2013, 5:20pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/1 "2013-11-27T17:20:22Z")

</div>

Hi !  
I need to parse the simulation.log and calculate statistics myself (min, max, mean etc etc)  
I don’t manage to recalculate the Global requests per second for each request, like it’s done in the “Response time against the Global requests per second” graph.  
What is the algorithm used ?

Thanks.  
Regards.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [November 27, 2013, 5:22pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/2 "2013-11-27T17:22:22Z")

</div>

What do you mean by “don’t manage”? You don’t get the same numbers, or you don’t know how to proceed?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [November 27, 2013, 5:26pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/3 "2013-11-27T17:26:45Z")

</div>

Basically, you get two time series, one for the response time and one for the number of requests per sec, and you then match them.

---

<div class="post-metadata">

**Author:** ![Ak\_Ak](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Ak\_Ak](https://community.gatling.io/u/Ak_Ak)\
**Post date:** [November 27, 2013, 9:09pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/4 "2013-11-27T21:09:53Z")

</div>

Sorry, I replied to you directly by mail, not in this discussion, I’m new with Google groups usage 😛

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [November 27, 2013, 9:12pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/5 "2013-11-27T21:12:34Z")

</div>

Times are rounded up in order not to display too many dots in the graph.

---

<div class="post-metadata">

**Author:** ![Ak\_Ak](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Ak\_Ak](https://community.gatling.io/u/Ak_Ak)\
**Post date:** [November 28, 2013, 1:49pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/6 "2013-11-28T13:49:00Z")

</div>

Désolé, je vais parler en français, ça ira plus vite 🙂  
Ce que je n’arrive pas à faire, c’est trouver la formule mathématique, le bout de code qui, en parsant simulation.log, permet de calculer le hits per sec Global par requête. Avec un exemple ça ira mieux, voici 2 exemples de vaines tentatives (ce ne sont que deux exemples, j’en ai essayé d’autres avec le timestamp de fin de réponse) c’est en Python :

secavant = 0  
secapres = 0

###tab2 est un tableau de tableaux contenant [timestamp\_debut\_requete,timestamp\_fin\_reponse,responsetime] de chaque requête.  
###pour 3 requêtes ça donnerait ça =\> [[1385646024422, 1385646024553, 131], [1385646024417, 1385646024556, 139], [1385646024428, 1385646024556, 128]]

###test calcul 1  
###je prends toutes les requêtes qui commencent 500ms avant ou après le timestamp de début de chaque requête pour calculer les hits/s global pour chacune d’elles  
for x in tab2:  
for i in tab2:  
secavant = i[0] - 500  
secapres = i[0] + 500  
if secavant \<= x[0] \<= secapres:  
hits+=1  
x.append(hits)  
hits=0

###test calcul 2  
###je prends toutes les requêtes qui commencent 1 seconde avant le timestamp de début de chaque requête pour calculer les hits/s global pour chacune d’elles  
for x in tab2:  
secavant = x[0] - 1000  
for i in tab2:  
if secavant \<= i[0] \<= x[0]:  
hits+=1  
x.append(hits)  
hits=0

### tab2 contient maintenant [timestamp\_debut\_requete,timestamp\_fin\_reponse,responsetime,hits\_per\_sec\_global] de chaque requête.

###pour 3 requêtes ça donnerait ça =\> [[1385646024422, 1385646024553, 131,5], [1385646024417, 1385646024556, 139,10], [1385646024428, 1385646024556, 128,5]]

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [November 28, 2013, 5:02pm UTC](https://community.gatling.io/t/global-requests-per-second-calculation/696/7 "2013-11-28T17:02:21Z")

</div>

As I said, we use buckets in order to limit the number of dots in the chart, so you don’t get one dot per sec like you do.  
You can have a look here (but good lick with that):  
[https://github.com/excilys/gatling/blob/master/gatling-charts/src/main/scala/io/gatling/charts/result/reader/FileDataReader.scala#L272-L280](https://github.com/excilys/gatling/blob/master/gatling-charts/src/main/scala/io/gatling/charts/result/reader/FileDataReader.scala#L272-L280)
