Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
2-tier calls vs 3-tier calls
(version: 0)
Testing the performance between using 2-tiers (controller-repository) vs 3-tiers (controller-service-repository)
Comparing performance of:
2-tier vs 3-tier
Created:
7 years ago
by:
Guest
Jump to the latest result
Tests:
2-tier
const data = {a: 1, b: 2, c:"some string", d: "some other string", e: 5.21, f: "The longest string ever for sure, but not quite"} const getData = () => { data.somethingElse = "yayyyy"; return data } const getFromDao = () => getData() const getFromController = () => getFromDao() getFromController()
3-tier
const data = {a: 1, b: 2, c:"some string", d: "some other string", e: 5.21, f: "The longest string ever for sure, but not quite"} const getData = () => data const getFromDao = () => getData() const getFromService = () => { const data = getFromDao(); data.somethingElse = "yayyy"; return data } const getFromController = () => getFromService() getFromController()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
2-tier
3-tier
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON data for the MeasureThat.net benchmark. **Benchmark Definition** The benchmark is comparing two approaches to calling functions: 1. **2-tier calls**: This approach involves making a direct call from the controller layer (getFromController) to the data access object (DAO) (getFromDao). The DAO then calls another function (getData) that returns the data. 2. **3-tier calls**: In this approach, an intermediate service layer is introduced between the controller and the DAO. The controller makes a call to the service layer (getFromService), which then makes a call to the DAO (getFromDao). The service layer modifies the returned data by adding a new property. **Options Compared** The two options being compared are: * **2-tier calls**: Direct call from controller to DAO, followed by a call to another function that returns the modified data. * **3-tier calls**: Call from controller to intermediate service layer, which then calls the DAO and modifies the returned data before returning it. **Pros and Cons** Here are some pros and cons of each approach: **2-tier calls:** Pros: * Less overhead due to fewer layers in the call stack * Easier to understand and maintain the flow of data Cons: * More direct coupling between controller and DAO, which can lead to tight coupling issues * Less flexibility if the structure of the system changes **3-tier calls:** Pros: * More decoupling between controller and DAO, making it easier to change or replace either component without affecting the other * More scalable, as additional service layers can be added without affecting the controller or DAO Cons: * More overhead due to additional layers in the call stack * May introduce more complexity and difficulty in understanding the flow of data **Other Considerations** In addition to these technical considerations, it's also worth noting that this benchmark is likely interested in performance differences between the two approaches. The **ExecutionsPerSecond** metric provided by MeasureThat.net suggests that there is a noticeable difference in performance between the two options. **Library and Special JS Features** There are no libraries explicitly mentioned in the Benchmark Definition or individual test cases. However, it's possible that some underlying frameworks or libraries (e.g., Express.js) might be implicitly involved. As for special JavaScript features, there are none explicitly mentioned in the provided data. If there were any, they would likely be related to the specific implementations of the 2-tier and 3-tier calls. **Alternatives** Other approaches that might be considered for this type of benchmark include: * **1-tier calls**: A direct call from the controller to a single function or service layer * **MVC (Model-View-Controller) patterns**: Following the traditional MVC pattern, where the controller would make calls to the model (DAO) and view layers * **Domain-Driven Design (DDD)**: Following DDD principles, which might involve more complex interactions between layers These alternatives could provide interesting variations on the 2-tier and 3-tier approaches, allowing for further exploration of performance differences or other aspects of system design.
Related benchmarks:
promise vs callback
just promise vs just callback
Promise vs async vs callbacks
callbacks vs promises vs async/awaits
Async vs Callback
Comments
Confirm delete:
Do you really want to delete benchmark?