Technical Recipes

drop test mongo db

> db.adminCommand("listDatabases").databases.forEach( function (d) {if(/^test/.test(d.name)) db.getSiblingDB(d.name).dropDatabase();})

measure load time of http request

$ curl -s -w 'Total Time:\t\t%{time_total}\n' -o /tmp/res "http://urox-staging.dbmx.io/sxs/sdmx/dataflow/UNICEF/all/latest?detail=full&references=all&tenant=urox"

Profile sxs

$ NODE_ENV=production node --prof index.js
$ node --prof-process isolate-0xnnnnnnnnnnnn-v8.log > processed.txt
 // 20250425 after many CRS data queries
 [Summary]:
   ticks  total  nonlib   name
   1233   18.4%   97.2%  JavaScript
      0    0.0%    0.0%  C++
    270    4.0%   21.3%  GC
   5442   81.1%          Shared libraries
     35    0.5%          Unaccounted

We can use Apache Bench or lxs to run multiple queries

$ ab -k -c 20 -n 250 "http://...

See: https://nodejs.org/en/learn/getting-started/profiling/