I've been testing my app's performance and found out that it takes 1 second from the time that data was posted to executing first line of action method. I'm testing this on empty rails 4 app (created using rails new app_name) and ruby 1.9.3-p448. I've only added one controller:
class TestController < ApplicationController
skip_before_filter :verify_authenticity_token
def testt
render json: {new: true}
end
end
and a route:
post "api/v1/tt" => "test#testt"
Here's the JSON that I'm posting:
{
"params": {
"updatedBy": "f092d32a-1e38-4f07-8b76-185393138d86",
"data": [
{
"typeName": "test",
"total": 995,
"timeOffset": 13,
"timestamp": 1404323549565,
"hidden": false,
"guid": "9fc91203-e558-43e1-b585-aefbd281c5f5",
"modificationDate": 1404316375054,
"deleted": false
},
{
"typeName": "test",
"total": 995,
"timeOffset": 13,
"timestamp": 1404323549565,
"hidden": false,
"guid": "9fc91203-e558-43e1-b585-aefbd281c5f5",
"modificationDate": 1404316375054,
"deleted": false
},
{
"typeName": "test",
"total": 995,
"timeOffset": 13,
"timestamp": 1404323549565,
"hidden": false,
"guid": "9fc91203-e558-43e1-b585-aefbd281c5f5",
"modificationDate": 1404316375054,
"deleted": false
},
{
"typeName": "test",
"total": 995,
"timeOffset": 13,
"timestamp": 1404323549565,
"hidden": false,
"guid": "9fc91203-e558-43e1-b585-aefbd281c5f5",
"modificationDate": 1404316375054,
"deleted": false
},
{
"typeName": "test",
"total": 995,
"timeOffset": 13,
"timestamp": 1404323549565,
"hidden": false,
"guid": "9fc91203-e558-43e1-b585-aefbd281c5f5",
"modificationDate": 1404316375054,
"deleted": false
}
]
}
}
using this command:
curl -H "Content-Type: application/json" -b cookies -c cookies --request POST "http://localhost/api/v1/tt" --data "@upload.json" -w "@timings-format.txt"
timings-format.txt contains:
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
When I run the command, I get something like this:
{"new":true}
time_namelookup: 0,001
time_connect: 0,001
time_appconnect: 0,000
time_pretransfer: 0,001
time_redirect: 0,000
time_starttransfer: 1,003
----------
time_total: 1,010
If I minify the JSON like this:
{"params":{"updatedBy":"f092d32a-1e38-4f07-8b76-185393138d86","data":[{"typeName":"test","total":995,"timeOffset":13,"timestamp":1404323549565,"hidden":false,"guid":"9fc91203-e558-43e1-b585-aefbd281c5f5","modificationDate":1404316375054,"deleted":false},{"typeName":"test","total":995,"timeOffset":13,"timestamp":1404323549565,"hidden":false,"guid":"9fc91203-e558-43e1-b585-aefbd281c5f5","modificationDate":1404316375054,"deleted":false},{"typeName":"test","total":995,"timeOffset":13,"timestamp":1404323549565,"hidden":false,"guid":"9fc91203-e558-43e1-b585-aefbd281c5f5","modificationDate":1404316375054,"deleted":false},{"typeName":"test","total":995,"timeOffset":13,"timestamp":1404323549565,"hidden":false,"guid":"9fc91203-e558-43e1-b585-aefbd281c5f5","modificationDate":1404316375054,"deleted":false},{"typeName":"test","total":995,"timeOffset":13,"timestamp":1404323549565,"hidden":false,"guid":"9fc91203-e558-43e1-b585-aefbd281c5f5","modificationDate":1404316375054,"deleted":false}]}}
and the run the command again, I get:
{"new":true}
time_namelookup: 0,001
time_connect: 0,002
time_appconnect: 0,000
time_pretransfer: 0,002
time_redirect: 0,000
time_starttransfer: 0,008
----------
time_total: 0,008
Does anyone have an idea of what is going on? I also have larger JSON that is minified but it still takes 1 second to execute empty action...