Faker.js: require('faker') is very slow, takes about 60ms

Created on 29 Jan 2015  路  5Comments  路  Source: Marak/faker.js

Here's a sample file which reproduces the issue on my machine; I'm running faker 2.0.0

var time = Date.now();
var faker = require('faker');
console.log("Loading faker took " + (Date.now() - time) + "ms");

// For comparison
time = Date.now();
var uuid = require('node-uuid');
console.log("Loading uuid took " + (Date.now() - time) + "ms");

What is going on that takes Faker so long to load? When your tests take less than 1ms each to execute, it's odd to see a 60ms slowdown.

Most helpful comment

In master, we now have the ability to individually require faker locales without having to load all of them.

Should should help a bit.

var faker = require('faker/locale/en');

All 5 comments

Could there be a workaround/ a way to load less data on system start?

Related Issue #125

@kevinburke - The work-around would be to comment out the locale requires you aren't using in this file: https://github.com/Marak/faker.js/blob/master/lib/locales.js

Closing for now. If anyone has issues with the work-around please let me know.

In master, we now have the ability to individually require faker locales without having to load all of them.

Should should help a bit.

var faker = require('faker/locale/en');
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aleyasen picture Aleyasen  路  6Comments

JeffBeltran picture JeffBeltran  路  5Comments

developdeez picture developdeez  路  5Comments

chenweiyj picture chenweiyj  路  4Comments

ghost picture ghost  路  4Comments