{ "id": "115270", "key": "TIMOB-14083", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2013-05-31T07:17:40.000+0000", "priority": null, "labels": [ "math", "modules", "performance", "random", "titanium" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:53.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [], "description": "*Problem*\r\nIt seems that the generation of random numbers by Math.random() is not performing well. I've done an experiment where I generate random 8-char strings, and then I check the performance on Titanium, node and native iOS, and the results are quite conclusive. Find a detailed description of the experiment here: http://developer.appcelerator.com/question/153040/titanium-performance-generating-random-strings \r\n\r\n*Test Case*\r\nThe experiment I did to test this lack of performance was the following: I coded the same random string generator algorithm in javascript and objC. This is how it looks in javascript:\r\n\r\n{{function randomId (length) {}}\r\n{{var textArray = [];}}\r\n{{var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";}}\r\n{{for( var i=0; i < length; i++)}}\r\n {{textArray.push(possible.charAt(Math.floor(Math.random() * possible.length)));}}\r\n \r\n{{return textArray.join('');}}\r\n{{}}}\r\n\r\n*Results*\r\nAnd then I perform a test where I generate one million of 8-char strings using this algorithm, I store them in an array, and I check for duplicates. The results are:\r\n\r\n - When I run it with Titanium (iPhone simulator), I get an average of 40 repeated strings.\r\n - When I run it with node (same javascript code), I get NO repeated strings.\r\n - When I run it with XCode (the objC version of the algorithm) using the iPhone simulator, I get NO repeated strings.\r\n\r\n*Conclusion*\r\nIt seems that there is an important lack of performance of the {{Math.random()}} method in the Titanium environment.\r\n", "attachment": [], "flagged": false, "summary": "Math.random() needs to be fixed", "creator": { "name": "tufosa", "key": "tufosa", "displayName": "Diego Lafuente", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "255239", "author": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Diego,\n\nThanks for bringing this to our attention, sorry to hear a similar bug was overlooked in the past. I'll make sure engineering takes a look at this. I know it is a bit much to ask, but for clarity and completeness sake of the ticket would you mind filling out the pertinent information from your post into the description here? It would save a lot of time and we would appreciate the clarity and concise location of all necessary information.\n\nRegards,\n\nCarter", "updateAuthor": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-31T19:31:38.000+0000", "updated": "2013-05-31T19:31:38.000+0000" }, { "id": "255451", "author": { "name": "tufosa", "key": "tufosa", "displayName": "Diego Lafuente", "active": true, "timeZone": "Europe/Berlin" }, "body": "Done!! Please let me know if you need more details about it.", "updateAuthor": { "name": "tufosa", "key": "tufosa", "displayName": "Diego Lafuente", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-06-03T07:40:15.000+0000", "updated": "2013-06-03T07:40:15.000+0000" }, { "id": "255519", "author": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks Diego! Great work on this, will pass along to engineering.\n\nBest Regards,\nCarter", "updateAuthor": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-03T17:08:26.000+0000", "updated": "2013-06-03T17:08:26.000+0000" }, { "id": "351493", "author": { "name": "ndastur", "key": "ndastur", "displayName": "Neville Dastur", "active": true, "timeZone": "Europe/London" }, "body": "Any news on this?", "updateAuthor": { "name": "ndastur", "key": "ndastur", "displayName": "Neville Dastur", "active": true, "timeZone": "Europe/London" }, "created": "2015-05-03T19:10:29.000+0000", "updated": "2015-05-03T19:10:29.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }