I want to analyze the amount of traffic certain scripts use when communicating with DB. I use mysqli_connect
, then I do mysqli_query
and then usually mysqli_fetch_assoc
or mysqli_fetch_array
. I want to know how many bytes are transferred for any given query. This will of course depend on how many times I call "fetch" methods. I can easily keep counters and sum them up, but how to get the correct values?
The best thing I can think of is calculate size of array returned by these fetch functions. Given that there is no byte_size_of() function in PHP, Id have to foreach
through them and sum strlen()
of every single value. But this obviously is bad approach, since these values wont be exactly what is received.
Thanks for help!
Note: the answers in How to calculate size from my query MySQL? or How to get the byte size of resultset in an SQL query? do not answer how to get it from PHP. I cant edit eveyr query and do it this way, I need a way to get file size from withing the PHP.