In my C# application, I have the following function:
foreach (var p in proglist)
{
programData.GetData1= new List<GetData1_ViewModel>(GetData1(programid, reportingdate));
programData.GetData2= new List<GetData2_ViewModel>(GetData2(programid, reportingdate));
programData.GetData3= new List<GetData3_ViewModel>(GetData3(programid, reportingdate));
programData.GetData4= new List<GetData4_ViewModel>(GetData4(programid, reportingdate));
programData.GetData5= new List<GetData5_ViewModel>(GetData5(programid, reportingdate));
}
Similarly, in my Typescript application, I have the matching function:
for (const p of proglist) {
this.data1 = [];
this.data2 = [];
this.data3 = [];
this.data4 = [];
this.data5 = [];
await Promise.all([
(this.data1 = await this.GetMeasureForScorecard(p.programId, reportingdate, "GetData1")),
(this.data2 = await this.GetMeasureForScorecard(p.programId, reportingdate, "GetData2")),
(this.data3 = await this.GetMeasureForScorecard(p.programId, reportingdate, "GetData3")),
(this.data4 = await this.GetData4(p.programId, reportingdate, "GetData4")),
(this.data5 = await this.GetData5(p.programId, reportingdate, "GetData5")),
]);
}
Both functions interact with the same database tables and stored procedures.
Surprisingly, the C# code completes in 5 seconds, while the Typescript code takes 189 seconds.
I am puzzled by the significant speed difference between the two. What optimizations can I implement to improve the performance of the Typescript function?