Test (v2)

Revision 2 of this benchmark created on


Setup

class QuoteModelUsingClasses {
	static fromDTO = ({ bid, ask }) => {
		return new QuoteModelUsingClasses(bid, ask)
	}
		
	constructor(bid, ask) {
		this.bid = bid;
		this.ask = ask;
	}
}

class QuoteModelUsingStaticMethods {
	static getAsk(obj) {
		return obj.ask
	}

	static getBid(obj) {
		return obj.bid
	}
}

Test runner

Ready to run.

Testing in
TestOps/sec
Creating objects
const dto = { bid: 1, ask: 2 }
const quote = QuoteModelUsingClasses.fromDTO(dto);
quote.bid + quote.ask
ready
creating objects 2
const quote = { bid: 1, ask: 2 }
QuoteModelUsingStaticMethods.getAsk(quote) + QuoteModelUsingStaticMethods.getBid(quote)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.