{"action":"closed","issue":{"url":"https://api.github.com/repos/stedolan/jq/issues/808","labels_url":"https://api.github.com/repos/stedolan/jq/issues/808/labels{/name}","comments_url":"https://api.github.com/repos/stedolan/jq/issues/808/comments","events_url":"https://api.github.com/repos/stedolan/jq/issues/808/events","html_url":"https://github.com/stedolan/jq/issues/808","id":86385793,"number":808,"title":"Debugging & performance tuning","user":{"login":"ssimeonov","id":491953,"avatar_url":"https://avatars.githubusercontent.com/u/491953?v=3","gravatar_id":"","url":"https://api.github.com/users/ssimeonov","html_url":"https://github.com/ssimeonov","followers_url":"https://api.github.com/users/ssimeonov/followers","following_url":"https://api.github.com/users/ssimeonov/following{/other_user}","gists_url":"https://api.github.com/users/ssimeonov/gists{/gist_id}","starred_url":"https://api.github.com/users/ssimeonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssimeonov/subscriptions","organizations_url":"https://api.github.com/users/ssimeonov/orgs","repos_url":"https://api.github.com/users/ssimeonov/repos","events_url":"https://api.github.com/users/ssimeonov/events{/privacy}","received_events_url":"https://api.github.com/users/ssimeonov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/stedolan/jq/labels/feature%20request","name":"feature request","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/stedolan/jq/milestones/3","html_url":"https://github.com/stedolan/jq/milestones/1.5%20release","labels_url":"https://api.github.com/repos/stedolan/jq/milestones/3/labels","id":682789,"number":3,"title":"1.5 release","description":"jq 1.5 should get all the features that won't be going into 1.4:\r\n\r\n - loadable modules\r\n - better jq library support\r\n - regexp/glob support\r\n - I/O primitives\r\n - generator primitives: `while`,\r\n - generator utils: `foreach`, `limit`\r\n - `try EXP catch EXP` (exceptions)\r\n - bignum support\r\n - anything else?","creator":{"login":"nicowilliams","id":604851,"avatar_url":"https://avatars.githubusercontent.com/u/604851?v=3","gravatar_id":"","url":"https://api.github.com/users/nicowilliams","html_url":"https://github.com/nicowilliams","followers_url":"https://api.github.com/users/nicowilliams/followers","following_url":"https://api.github.com/users/nicowilliams/following{/other_user}","gists_url":"https://api.github.com/users/nicowilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/nicowilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicowilliams/subscriptions","organizations_url":"https://api.github.com/users/nicowilliams/orgs","repos_url":"https://api.github.com/users/nicowilliams/repos","events_url":"https://api.github.com/users/nicowilliams/events{/privacy}","received_events_url":"https://api.github.com/users/nicowilliams/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":99,"state":"open","created_at":"2014-06-05T23:19:44Z","updated_at":"2015-07-26T23:14:11Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2015-06-09T00:34:01Z","updated_at":"2015-07-26T23:14:11Z","closed_at":"2015-07-26T23:14:11Z","body":"I am used to `jq` being very fast most of the time so it's surprising when a script seems to execute very slowly. This happened to me over the weekend and, in the process of diagnosing the problem, I realized that `jq` has extremely limited debugging & performance tuning abilities. I wonder what others are doing when faced with these issues and what is a minimal set of capabilities that could support more complex `jq` scripts. \r\n\r\nMy standard approach to debugging is to generate multiple outputs, e.g., \r\n\r\n```\r\n.foo | ., .bar\r\n```\r\n\r\nThis works to an extent but has the following problems:\r\n\r\n1. Diagnostic output (`.` in the above case) is mixed with real output on STDOUT.\r\n1. A script error can prevent the diagnostic output, strangely, even if it happens after it?\r\n1. This can't help performance tuning.\r\n\r\nA minimal set of features that could be very helpful could be:\r\n\r\n- The ability to output to STDERR\r\n- The ability to output the current time as milliseconds since epoch\r\n\r\nThe above example could then become something like:\r\n\r\n```\r\n.foo | ([now, .] | stderr), .bar\r\n```\r\n\r\nSTDERR could be post-processed with `grep` (to filter non JSON output, e.g., error messages) and then `jq` to analyze the diagnostic output (likely with `--slurp`). Because of this, `stderr` output should always be compact and in JSON format.\r\n\r\nBeyond the minimal feature set, I would really enjoy having a set of lap timers that work along the lines of:\r\n\r\n```\r\n# Assume prologue, work & epilogue are functions\r\nstart_lap(0) | prologue |\r\n.[] |\r\nstart_lap(1) | work | end_lap(1) |\r\nepilogue | end_lap(0) |\r\n(timers | stderr), .\r\n```\r\n\r\nI could imagine `timers` to output something like the following on STDERR:\r\n\r\n```\r\n[[start of first lap timestamp, end of last lap timestamp, number of laps, milliseconds per lap], ...]\r\n```\r\n\r\nIs there anything in the works to help debugging & performance tuning? What are others doing?"}}