A demo application designed to compare the speed of a REST API using both JSON and protocol buffers
- Node.js v6.x.x or above.
- Clone repo to local directory
- Run
npm install
- Run
npm start
- Navigate to http://localhost:3000
- Choose test type to run and amount of passes for each test
- Click Start Tests to begin
- Open console to view test progress and result summaries
One test will consist of a series of get calls for both protocol buffers and JSON.
- Produce a random string (of predetermined size) for all data keys included in the specific test
- Data size will start at 1 byte
- Data size will increase by 50% with each following call
- Data size will increase to a maximum size (varies depending on test type)
- When max data size has been reached the same steps listed above will be repeated for the alternate API type
When all get calls have been made for both protocol buffer and JSON API's, that is considered one pass. You can specify the amount of passes to be run for each test by using the slider in the UI. Default is 10 passes.
- Two tables will be added to UI displaying the results of every get call made for both API's
- The percent difference will be calculated between the different API calls for each data size
- For example, during one pass the results of the protocol buffer API with count 1 will be compared to the JSON API with count 1
- The percent differences for all counts and for all passes will be averaged out to display an overall percent increase or decrease in the API's performance
- All results are represented using JSON as the baseline and comparing it to protocol buffers (percent decrease indicates protocol buffers were faster)
- Time from start of get call till response of get call
- Time from response till decoded data (UI usable data)
- Overall time from initial get request to usable UI data
- Size of response data from the get call
Regular message tests will create the following object to be sent back client
{
count: 4, \\ determines the size of data keys to be created
data: "adsfsadf", \\ random string of data where the length and size are determined by count
isFinal: false, \\ when count has reached a predetermined amount isFinal will be true ending the single test run
}
Tall message tests will create an object similar to the regular message but with 25 data keys to be sent back client
{
count: 4, \\ determines the size of data keys to be created
data0: "adsfsadf", \\ random string of data where the length and size are determined by count
data1: "adsfsadf", \\ random string of data where the length and size are determined by count
data2: "adsfsadf", \\ random string of data where the length and size are determined by count
...
data24: "adsfsadf", \\ random string of data where the length and size are determined by count
isFinal: false, \\ when count has reached a predetermined amount isFinal will be true ending the single test run
}