• Performance issues

    By Sanmao Zhao 1 decade ago

    I processing a large text(15K) with JSONReader.parse method, probably to spend 0.5 seconds of time, there is any way to improve it?
    Thank you!


    Here is the code:

    Sub Initialize

    Dim j As JSONReader
    Set j = New JSONReader
    Dim lTicksStart  As Long
    Dim lTicksStop   As Long
    Dim lTicksperSec As Long
    
    lTicksStart = GetThreadInfo(6)
    
    Call j.Parse(|{"fathers":[{"id":0,"married":false,"name":"RichardWilliams","sons":null,"daughters":[{"age":3,"name":"Betty"}]},{"id":1,"married":false,"name":"WilliamWhite","sons":null,"daughters":[{"age":28,"name":"Jennifer"}]},{"id":2,"married":false,"name":"RonaldMoore","sons":null,"daughters":[{"age":18,"name":"Karen"},{"age":6,"name":"Mary"}]},{"id":3,"married":false,"name":"JasonTaylor","sons":null,"daughters":[{"age":20,"name":"Nancy"}]},{"id":4,"married":false,"name":"StevenDavis","sons":null,"daughters":[{"age":12,"name":"Barbara"},{"age":27,"name":"Melissa"},{"age":31,"name":"Anna"}]},{"id":5,"married":true,"name":"PaulBrown","sons":null,"daughters":[{"age":17,"name":"Betty"}]},{"id":6,"married":true,"name":"JeffreyWhite","sons":null,"daughters":[{"age":10,"name":"Margaret"},{"age":14,"name":"Brenda"}]},{"id":7,"married":true,"name":"JosephThomas","sons":null,"daughters":[{"age":1,"name":"Mary"},{"age":27,"name":"Patricia"}]},{"id":8,"married":true,"name":"JamesDavis","sons":null,"daughters":[{"age":3,"name":"Karen"}]},{"id":9,"married":false,"name":"MatthewMartin","sons":null,"daughters":[]},{"id":10,"married":false,"name":"JosephGarcia","sons":null,"daughters":[{"age":25,"name":"Donna"}]},{"id":11,"married":true,"name":"ThomasLee","sons":null,"daughters":[{"age":8,"name":"Lisa"},{"age":4,"name":"Betty"}]},{"id":12,"married":true,"name":"EdwardJackson","sons":null,"daughters":[{"age":7,"name":"Mary"},{"age":28,"name":"Lisa"}]},{"id":13,"married":false,"name":"JohnRodriguez","sons":null,"daughters":[{"age":31,"name":"Sandra"}]},{"id":14,"married":true,"name":"GaryAnderson","sons":null,"daughters":[{"age":17,"name":"Karen"}]},{"id":15,"married":false,"name":"GaryPerez","sons":null,"daughters":[]},{"id":16,"married":true,"name":"StevenMartinez","sons":null,"daughters":[{"age":13,"name":"Jennifer"},{"age":6,"name":"Sandra"}]},{"id":17,"married":true,"name":"ScottAnderson","sons":null,"daughters":[{"age":31,"name":"Jennifer"},{"age":5,"name":"Carol"}]},{"id":18,"married":true,"name":"JasonBrown","sons":null,"daughters":[{"age":8,"name":"Maria"},{"age":18,"name":"Angela"}]},{"id":19,"married":false,"name":"RichardRobinson","sons":null,"daughters":[{"age":26,"name":"Cynthia"},{"age":20,"name":"Dorothy"},{"age":17,"name":"Elizabeth"}]},{"id":20,"married":true,"name":"DonaldWhite","sons":null,"daughters":[{"age":19,"name":"Linda"}]},{"id":21,"married":false,"name":"EricMartinez","sons":null,"daughters":[{"age":30,"name":"Betty"}]},{"id":22,"married":true,"name":"GeorgeMartinez","sons":null,"daughters":[{"age":17,"name":"Donna"},{"age":5,"name":"Sharon"}]},{"id":23,"married":false,"name":"ScottTaylor","sons":null,"daughters":[{"age":5,"name":"Sarah"},{"age":15,"name":"Shirley"}]},{"id":24,"married":false,"name":"AnthonyYoung","sons":null,"daughters":[]},{"id":25,"married":false,"name":"KevinRodriguez","sons":null,"daughters":[{"age":27,"name":"Linda"},{"age":27,"name":"Deborah"}]},{"id":26,"married":true,"name":"CharlesThomas","sons":null,"daughters":[{"age":6,"name":"Cynthia"},{"age":31,"name":"Melissa"},{"age":27,"name":"Sarah"}]},{"id":27,"married":false,"name":"GaryHall","sons":null,"daughters":[{"age":24,"name":"Lisa"},{"age":26,"name":"Amy"}]},{"id":28,"married":false,"name":"JosephThomas","sons":null,"daughters":[{"age":26,"name":"Michelle"}]},{"id":29,"married":true,"name":"RobertWilliams","sons":null,"daughters":[]},{"id":30,"married":false,"name":"WilliamThompson","sons":null,"daughters":[{"age":18,"name":"Lisa"},{"age":23,"name":"Deborah"}]},{"id":31,"married":false,"name":"JohnGonzalez","sons":null,"daughters":[{"age":1,"name":"Susan"}]},{"id":32,"married":false,"name":"BrianRobinson","sons":null,"daughters":[]},{"id":33,"married":false,"name":"LarryMartinez","sons":null,"daughters":[]},{"id":34,"married":false,"name":"PaulHernandez","sons":null,"daughters":[{"age":14,"name":"Anna"},{"age":23,"name":"Brenda"},{"age":23,"name":"Sandra"}]},{"id":35,"married":true,"name":"WilliamMartinez","sons":null,"daughters":[{"age":2,"name":"Sharon"}]},{"id":36,"married":true,"name":"ScottSmith","sons":null,"daughters":[{"age":12,"name":"Susan"}]},{"id":37,"married":true,"name":"LarryJackson","sons":null,"daughters":[{"age":21,"name":"Betty"}]},{"id":38,"married":true,"name":"JeffreyLewis","sons":null,"daughters":[{"age":13,"name":"Amy"},{"age":11,"name":"Anna"}]},{"id":39,"married":true,"name":"DonaldJones","sons":null,"daughters":[]},{"id":40,"married":false,"name":"DavidWalker","sons":null,"daughters":[{"age":18,"name":"Deborah"},{"age":8,"name":"Linda"}]},{"id":41,"married":false,"name":"JohnAllen","sons":null,"daughters":[{"age":25,"name":"Donna"},{"age":23,"name":"Angela"},{"age":11,"name":"Brenda"}]},{"id":42,"married":true,"name":"MarkRodriguez","sons":null,"daughters":[{"age":5,"name":"Cynthia"}]},{"id":43,"married":false,"name":"ThomasLewis","sons":null,"daughters":[{"age":24,"name":"Anna"},{"age":4,"name":"Angela"}]},{"id":44,"married":true,"name":"FrankThompson","sons":null,"daughters":[{"age":9,"name":"Mary"},{"age":25,"name":"Michelle"}]},{"id":45,"married":false,"name":"DanielAllen","sons":null,"daughters":[{"age":7,"name":"Sandra"},{"age":13,"name":"Anna"},{"age":5,"name":"Deborah"}]},{"id":46,"married":false,"name":"JasonJones","sons":null,"daughters":[]},{"id":47,"married":false,"name":"PaulMartinez","sons":null,"daughters":[{"age":7,"name":"Jennifer"},{"age":28,"name":"Susan"}]},{"id":48,"married":false,"name":"WilliamJackson","sons":null,"daughters":[{"age":22,"name":"Jessica"},{"age":14,"name":"Linda"}]},{"id":49,"married":true,"name":"RonaldJones","sons":null,"daughters":[{"age":4,"name":"Helen"}]},{"id":50,"married":false,"name":"BrianClark","sons":null,"daughters":[{"age":7,"name":"Jessica"},{"age":17,"name":"Patricia"}]},{"id":51,"married":true,"name":"CharlesRodriguez","sons":null,"daughters":[{"age":1,"name":"Angela"},{"age":21,"name":"Patricia"},{"age":18,"name":"Patricia"}]},{"id":52,"married":true,"name":"BrianWilliams","sons":null,"daughters":[{"age":4,"name":"Brenda"}]},{"id":53,"married":false,"name":"ScottPerez","sons":null,"daughters":[{"age":9,"name":"Karen"},{"age":11,"name":"Jessica"}]},{"id":54,"married":false,"name":"TimothyHernandez","sons":null,"daughters":[{"age":28,"name":"Sarah"},{"age":19,"name":"Michelle"}]},{"id":55,"married":true,"name":"RobertWilson","sons":null,"daughters":[]},{"id":56,"married":true,"name":"FrankLopez","sons":null,"daughters":[{"age":18,"name":"Lisa"},{"age":29,"name":"Kimberly"},{"age":17,"name":"Angela"}]},{"id":57,"married":true,"name":"LarryJones","sons":null,"daughters":[{"age":21,"name":"Shirley"},{"age":11,"name":"Helen"}]},{"id":58,"married":false,"name":"KevinGonzalez","sons":null,"daughters":[]},{"id":59,"married":false,"name":"GeorgeMartin","sons":null,"daughters":[{"age":14,"name":"Margaret"}]},{"id":60,"married":false,"name":"JosephJohnson","sons":null,"daughters":[{"age":15,"name":"Patricia"},{"age":5,"name":"Shirley"}]},{"id":61,"married":true,"name":"BrianWilson","sons":null,"daughters":[{"age":5,"name":"Susan"}]},{"id":62,"married":false,"name":"GeorgeThomas","sons":null,"daughters":[{"age":10,"name":"Barbara"},{"age":16,"name":"Susan"},{"age":18,"name":"Maria"}]},{"id":63,"married":false,"name":"JamesLewis","sons":null,"daughters":[{"age":25,"name":"Susan"},{"age":21,"name":"Sandra"}]},{"id":64,"married":true,"name":"MarkLopez","sons":null,"daughters":[{"age":6,"name":"Elizabeth"}]},{"id":65,"married":false,"name":"StevenMiller","sons":null,"daughters":[{"age":17,"name":"Amy"}]},{"id":66,"married":true,"name":"MichaelHall","sons":null,"daughters":[{"age":13,"name":"Sharon"}]},{"id":67,"married":false,"name":"DonaldRobinson","sons":null,"daughters":[{"age":17,"name":"Deborah"},{"age":21,"name":"Patricia"}]},{"id":68,"married":false,"name":"DonaldDavis","sons":null,"daughters":[{"age":2,"name":"Melissa"},{"age":26,"name":"Anna"}]},{"id":69,"married":false,"name":"TimothyRobinson","sons":null,"daughters":[{"age":8,"name":"Angela"},{"age":26,"name":"Sandra"}]},{"id":70,"married":false,"name":"JamesAnderson","sons":null,"daughters":[{"age":19,"name":"Anna"},{"age":10,"name":"Dorothy"},{"age":12,"name":"Kimberly"}]},{"id":71,"married":false,"name":"MarkHarris","sons":null,"daughters":[{"age":19,"name":"Betty"},{"age":8,"name":"Helen"}]},{"id":72,"married":true,"name":"ThomasAllen","sons":null,"daughters":[{"age":17,"name":"Donna"}]},{"id":73,"married":true,"name":"JoseJackson","sons":null,"daughters":[{"age":2,"name":"Sandra"},{"age":13,"name":"Elizabeth"}]},{"id":74,"married":true,"name":"RobertClark","sons":null,"daughters":[{"age":7,"name":"Melissa"},{"age":25,"name":"Anna"}]},{"id":75,"married":true,"name":"GeorgeDavis","sons":null,"daughters":[{"age":27,"name":"Donna"},{"age":20,"name":"Elizabeth"}]},{"id":76,"married":false,"name":"MichaelYoung","sons":null,"daughters":[{"age":20,"name":"Nancy"},{"age":9,"name":"Barbara"}]},{"id":77,"married":false,"name":"RonaldPerez","sons":null,"daughters":[{"age":14,"name":"Sarah"},{"age":27,"name":"Betty"}]},{"id":78,"married":false,"name":"RobertDavis","sons":null,"daughters":[{"age":19,"name":"Angela"}]},{"id":79,"married":false,"name":"JohnMartin","sons":null,"daughters":[{"age":6,"name":"Mary"},{"age":27,"name":"Michelle"}]},{"id":80,"married":false,"name":"PaulSmith","sons":null,"daughters":[{"age":13,"name":"Susan"},{"age":29,"name":"Linda"},{"age":7,"name":"Betty"}]},{"id":81,"married":false,"name":"MarkGarcia","sons":null,"daughters":[{"age":7,"name":"Deborah"}]},{"id":82,"married":false,"name":"RobertGarcia","sons":null,"daughters":[{"age":28,"name":"Susan"}]},{"id":83,"married":true,"name":"TimothyThompson","sons":null,"daughters":[]},{"id":84,"married":true,"name":"DanielGarcia","sons":null,"daughters":[]},{"id":85,"married":true,"name":"JoseYoung","sons":null,"daughters":[{"age":25,"name":"Mary"}]},{"id":86,"married":true,"name":"TimothyThomas","sons":null,"daughters":[{"age":22,"name":"Donna"}]},{"id":87,"married":true,"name":"DavidMartinez","sons":null,"daughters":[{"age":18,"name":"Patricia"}]},{"id":88,"married":false,"name":"CharlesThomas","sons":null,"daughters":[]},{"id":89,"married":false,"name":"EricMoore","sons":null,"daughters":[{"age":14,"name":"Brenda"},{"age":15,"name":"Betty"}]},{"id":90,"married":true,"name":"GaryAllen","sons":null,"daughters":[{"age":31,"name":"Deborah"},{"age":1,"name":"Margaret"},{"age":0,"name":"Sharon"}]},{"id":91,"married":true,"name":"TimothyJohnson","sons":null,"daughters":[{"age":22,"name":"Sarah"}]},{"id":92,"married":false,"name":"GaryGarcia","sons":null,"daughters":[{"age":31,"name":"Amy"},{"age":10,"name":"Betty"}]},{"id":93,"married":false,"name":"JohnClark","sons":null,"daughters":[{"age":10,"name":"Jessica"}]},{"id":94,"married":true,"name":"EdwardMiller","sons":null,"daughters":[]},{"id":95,"married":false,"name":"DanielMartinez","sons":null,"daughters":[{"age":16,"name":"Anna"}]},{"id":96,"married":true,"name":"RonaldPerez","sons":null,"daughters":[{"age":13,"name":"Donna"},{"age":21,"name":"Anna"},{"age":30,"name":"Elizabeth"}]},{"id":97,"married":false,"name":"JamesMartinez","sons":null,"daughters":[{"age":13,"name":"Laura"},{"age":15,"name":"Susan"}]},{"id":98,"married":false,"name":"PaulMartin","sons":null,"daughters":[{"age":17,"name":"Cynthia"}]},{"id":99,"married":false,"name":"EricThomas","sons":null,"daughters":[]},{"id":100,"married":false,"name":"KevinJones","sons":null,"daughters":[]},{"id":101,"married":false,"name":"KevinHarris","sons":null,"daughters":[{"age":2,"name":"Jessica"},{"age":4,"name":"Elizabeth"}]},{"id":102,"married":true,"name":"RonaldThompson","sons":null,"daughters":[{"age":31,"name":"Elizabeth"}]},{"id":103,"married":false,"name":"FrankThomas","sons":null,"daughters":[{"age":17,"name":"Dorothy"},{"age":9,"name":"Melissa"}]},{"id":104,"married":true,"name":"FrankHall","sons":null,"daughters":[{"age":24,"name":"Jessica"},{"age":27,"name":"Linda"}]},{"id":105,"married":false,"name":"KevinTaylor","sons":null,"daughters":[]},{"id":106,"married":true,"name":"ChristopherHarris","sons":null,"daughters":[{"age":17,"name":"Carol"},{"age":13,"name":"Linda"},{"age":29,"name":"Donna"}]},{"id":107,"married":true,"name":"DavidRodriguez","sons":null,"daughters":[{"age":7,"name":"Nancy"}]},{"id":108,"married":false,"name":"JohnMartinez","sons":null,"daughters":[{"age":1,"name":"Donna"}]},{"id":109,"married":false,"name":"StevenHarris","sons":null,"daughters":[{"age":9,"name":"Cynthia"}]},{"id":110,"married":true,"name":"RichardMartin","sons":null,"daughters":[]},{"id":111,"married":true,"name":"KevinWalker","sons":null,"daughters":[]},{"id":112,"married":false,"name":"JeffreyWilliams","sons":null,"daughters":[{"age":2,"name":"Maria"},{"age":26,"name":"Amy"}]},{"id":113,"married":false,"name":"StevenWalker","sons":null,"daughters":[{"age":21,"name":"Kimberly"}]},{"id":114,"married":true,"name":"BrianThomas","sons":null,"daughters":[{"age":10,"name":"Lisa"},{"age":19,"name":"Mary"}]},{"id":115,"married":true,"name":"KennethRodriguez","sons":null,"daughters":[{"age":30,"name":"Susan"},{"age":6,"name":"Michelle"}]},{"id":116,"married":true,"name":"DavidRodriguez","sons":null,"daughters":[{"age":29,"name":"Jessica"},{"age":25,"name":"Sharon"}]},{"id":117,"married":true,"name":"RichardSmith","sons":null,"daughters":[]},{"id":118,"married":true,"name":"ScottLopez","sons":null,"daughters":[{"age":10,"name":"Patricia"},{"age":4,"name":"Jessica"},{"age":16,"name":"Amy"}]},{"id":119,"married":false,"name":"JasonHall","sons":null,"daughters":[{"age":12,"name":"Sharon"},{"age":30,"name":"Carol"}]},{"id":120,"married":true,"name":"DonaldDavis","sons":null,"daughters":[{"age":19,"name":"Dorothy"}]},{"id":121,"married":true,"name":"EricPerez","sons":null,"daughters":[{"age":21,"name":"Brenda"}]},{"id":122,"married":true,"name":"StevenDavis","sons":null,"daughters":[{"age":21,"name":"Anna"},{"age":8,"name":"Angela"}]},{"id":123,"married":false,"name":"KennethMartinez","sons":null,"daughters":[{"age":20,"name":"Betty"}]},{"id":124,"married":true,"name":"CharlesMiller","sons":null,"daughters":[{"age":21,"name":"Ruth"}]},{"id":125,"married":false,"name":"RobertDavis","sons":null,"daughters":[{"age":28,"name":"Mary"},{"age":24,"name":"Laura"}]},{"id":126,"married":true,"name":"ThomasBrown","sons":null,"daughters":[{"age":9,"name":"Amy"},{"age":4,"name":"Dorothy"}]},{"id":127,"married":false,"name":"JohnJohnson","sons":null,"daughters":[{"age":23,"name":"Sharon"},{"age":1,"name":"Kimberly"}]},{"id":128,"married":false,"name":"ChristopherAnderson","sons":null,"daughters":[{"age":15,"name":"Mary"},{"age":29,"name":"Mary"}]},{"id":129,"married":true,"name":"MarkLopez","sons":null,"daughters":[{"age":18,"name":"Susan"},{"age":15,"name":"Donna"}]},{"id":130,"married":true,"name":"PaulBrown","sons":null,"daughters":[]},{"id":131,"married":true,"name":"TimothyLewis","sons":null,"daughters":[{"age":27,"name":"Nancy"}]},{"id":132,"married":true,"name":"JasonHall","sons":null,"daughters":[{"age":2,"name":"Melissa"},{"age":22,"name":"Brenda"}]},{"id":133,"married":false,"name":"EdwardLee","sons":null,"daughters":[{"age":13,"name":"Shirley"}]},{"id":134,"married":false,"name":"ChristopherPerez","sons":null,"daughters":[{"age":20,"name":"Anna"},{"age":19,"name":"Sharon"},{"age":20,"name":"Dorothy"}]},{"id":135,"married":true,"name":"ThomasBrown","sons":null,"daughters":[]},{"id":136,"married":false,"name":"GaryRobinson","sons":null,"daughters":[{"age":15,"name":"Helen"},{"age":23,"name":"Betty"},{"age":18,"name":"Lisa"}]},{"id":137,"married":false,"name":"MichaelJones","sons":null,"daughters":[{"age":7,"name":"Amy"},{"age":16,"name":"Shirley"},{"age":2,"name":"Elizabeth"}]},{"id":138,"married":false,"name":"DavidYoung","sons":null,"daughters":[{"age":5,"name":"Melissa"},{"age":11,"name":"Nancy"}]}]}|)
    lTicksStop   = GetThreadInfo(6)
    lTicksperSec = GetThreadInfo(7)
    
    MsgBox "b1 Elapsed time: " & (lTicksStop - lTicksStart)/ lTicksperSec
    

    End Sub

    • By Lars Berntrop 9 years ago

      I have a version that parses this string in ~110 ms, i.e. 0,11 secs. Note: the standard version times just as long on my computer, so it is not a hardware difference ;-)

      Still Lotusscript, also works if Java is not allowed.
      Interested?

      • By Sanmao Zhao 9 years ago

        Nice job!

        If you can upload to openntf? So that more people can benefit.
        Thanks!

        • By Lars Berntrop 7 years ago

          Finally came round to publishing it. You can find it as JSON LotusScript Classes turbo