What you tried should give, what you desired to get.
I mean the following:
curl "http://stackoverflow.com/" -w "\' %{http_code}\',\'%{time_total}\'"