{"action":"created","issue":{"url":"https://api.github.com/repos/svaarala/duktape/issues/183","labels_url":"https://api.github.com/repos/svaarala/duktape/issues/183/labels{/name}","comments_url":"https://api.github.com/repos/svaarala/duktape/issues/183/comments","events_url":"https://api.github.com/repos/svaarala/duktape/issues/183/events","html_url":"https://github.com/svaarala/duktape/issues/183","id":70273152,"number":183,"title":"Recursive Fibonacci extremely slow on TI-Nspire","user":{"login":"Legimet","id":7368196,"avatar_url":"https://avatars.githubusercontent.com/u/7368196?v=3","gravatar_id":"","url":"https://api.github.com/users/Legimet","html_url":"https://github.com/Legimet","followers_url":"https://api.github.com/users/Legimet/followers","following_url":"https://api.github.com/users/Legimet/following{/other_user}","gists_url":"https://api.github.com/users/Legimet/gists{/gist_id}","starred_url":"https://api.github.com/users/Legimet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Legimet/subscriptions","organizations_url":"https://api.github.com/users/Legimet/orgs","repos_url":"https://api.github.com/users/Legimet/repos","events_url":"https://api.github.com/users/Legimet/events{/privacy}","received_events_url":"https://api.github.com/users/Legimet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/svaarala/duktape/labels/performance","name":"performance","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/svaarala/duktape/milestones/9","html_url":"https://github.com/svaarala/duktape/milestones/v1.3.0","labels_url":"https://api.github.com/repos/svaarala/duktape/milestones/9/labels","id":1037290,"number":9,"title":"v1.3.0","description":"","creator":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"open_issues":39,"closed_issues":7,"state":"open","created_at":"2015-03-24T22:16:58Z","updated_at":"2015-04-23T06:08:12Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-04-23T01:00:31Z","updated_at":"2015-04-23T06:11:14Z","closed_at":null,"body":"The recursive Fibonacci algorithm is very slow on the Nspire. I am using Duktape 1.2.1, and compiling with -O3.\r\n\r\nHere is a minimal working example:\r\n\r\n```\r\n#include \"duktape.h\"\r\n\r\nint main(void) {\r\n  duk_context *ctx = duk_create_heap_default();\r\n  duk_eval_string(ctx, \"function f(n){if (n<=1) return n; else return f(n-1)+f(n-2)}print(f(30));\");\r\n  duk_destroy_heap(ctx);\r\n  return 0;\r\n}\r\n```\r\n\r\nComputing f(30) takes about 57 seconds. For comparison, here is a graph of computation times for various other languages available on this calculator: https://i.imgur.com/fBPlXr1.png. (We are using recursive Fibonacci as a benchmark.)"},"comment":{"url":"https://api.github.com/repos/svaarala/duktape/issues/comments/95452880","html_url":"https://github.com/svaarala/duktape/issues/183#issuecomment-95452880","issue_url":"https://api.github.com/repos/svaarala/duktape/issues/183","id":95452880,"user":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T06:11:14Z","updated_at":"2015-04-23T06:11:14Z","body":"It's a known issue and can be seen here too:\r\n\r\n- https://github.com/svaarala/duktape/issues/138#issuecomment-86065937\r\n\r\nThere are several reasons for this. For example, self reference (`function fib() { ... }` refers to `fib`) causes an explicit scope object to be created, and returning involves a longjmp. These weren't yet addressed in #138."}}