Performance in the test is terrible, is it normal in Meteor? -
here small test on performance of meteor 1.2.1.
performance.html
<head> <title>performance</title> </head> <body> <br><br> <form class="search-form"> <input type="text" name="keyword" placeholder="enter keyword search"> </form> <br> {{> items}} </body> <template name="items"> <table> <thead></thead> <tbody> {{#each items}} <tr> <td>{{first}}</td> <td>{{second}}</td> <td>{{third}}</td> </tr> {{/each}} </tbody> </table> </template>
performance.js
items = new mongo.collection('items'); if (meteor.isclient) { template.items.helpers({ items: function () { if (session.get('input')) { var keyword = session.get('input'); var regex = new regexp(keyword, "i"); return items.find({$or: [{first: regex}, {second: regex}, {third: regex}]}); } else { return items.find(); } } }); template.body.events({ "submit .search-form": function (events) { events.preventdefault(); var input = events.target.keyword.value; session.set('input', input); } }); } if (meteor.isserver) { meteor.startup(function () { // code run on server @ startup if (items.find().count() < 5000) { (var = 1; <= 5000; i++) { items.insert({first: 'first_' + i, second: 'second_' + i, third: 'third_' + i, createdat: new date()}); } } }); }
when load or refresh page chrome's developer tools shows took 3 seconds. , if input, e.g., 1 , hit enter, looks no response few seconds show result @ last. maybe suggestion said don't return collections, it's not big data (5k docs, 3 simple fields) return, did same thing using laravel 5 , mysql, works pretty smoothly, , tried query in mongodb cli looks good, what's problem on performance of meteor?
Comments
Post a Comment