ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[Bug]: Performance degradation observed in Ballerina version 2201.8.5 compared to 2201.8.4

Open gabilang opened this issue 11 months ago • 1 comments

Description

A slowness is observed in the version 2201.8.5 when using fromJsonWithType() for binding a large json to a record. It's taking much time for conversion than 2201.8.4

Steps to Reproduce

import ballerina/io;
import ballerina/time;


public type Person record {
    int id;
    string name;
    int age;
    string address;
    string? email;
    string? contact;
    string qualification;
    boolean isEmployed;
    decimal salary;
    boolean married;
    string? spouse;
    string[]? children;
};

public function main() returns error? {
    json responseJson = check io:fileReadJson("./random_data.json");
    time:Utc startTime = time:utcNow();
    Person[] _ = check responseJson.fromJsonWithType();
    time:Utc endTime = time:utcNow();
    time:Seconds difference = time:utcDiffSeconds(endTime, startTime);
    io:println("Time taken to parse the JSON: ", difference);
}

Output with 2201.8.5 ->

Time taken to parse the JSON: 7.038689

Output with 2201.8.4 ->

Time taken to parse the JSON: 0.235574

random_data.json

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

gabilang avatar Mar 25 '24 08:03 gabilang