5

Which has better performance?

I'm getting data and posting it to a different url, I can send both types but which should I choose? The data is a pdf file

user59388
  • 159
  • 1
  • 10
  • What do you mean by "posting"? – Bergi Jul 22 '15 at 08:49
  • They mean different things - an arraybuffer is a sequence of raw bytes, while a blob represents a file with an encoding. Since you mention pdf, the latter sounds more appropriate. – Bergi Jul 22 '15 at 08:50
  • Posting as in sending a post request with the data. I understand that they're different, both of them work for me in my case since I'm not doing anything with the file. My only concern is performance in this case – user59388 Jul 22 '15 at 08:56
  • Then try both and measure the performance. I'm inclined to guess that they are no different, though. – Bergi Jul 22 '15 at 08:57
  • How does one accurately measure the performance of ajax calls? – user59388 Jul 22 '15 at 09:00
  • Just look in the dev tools. Alternatively, log the timestamps of the events related to the ajax call. Or use [performance timing api](http://stackoverflow.com/a/17808655/1048572) – Bergi Jul 22 '15 at 09:04
  • 2
    You're right, virtually no difference in performance, if you post an answer I'll accept it – user59388 Jul 22 '15 at 09:32

1 Answers1

3

Which has better performance?

There should be virtually no difference.

I can send both types but which should I choose for a pdf file?

As a Blob does represent a file with an encoding (and is superclass to named Files), it seems more appropriate here than an ArrayBuffer which is a raw sequence of bytes.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375