Giter Site home page Giter Site logo

Comments (5)

ScottRobbins avatar ScottRobbins commented on August 19, 2024

I do expect developers to read these entries in git, so I would like to make it prettified JSON if possible.

I also want to benchmark before/after change: I think that because YAML is a superset of JSON, it should be slower to read and write. So there is hopefully a performance boost from this change, however that's not the main goal.

from changes.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

Before changes

8.63 real        38.94 user        19.56 sys
            52031488  maximum resident set size
                   0  average shared memory size
                   0  average unshared data size
                   0  average unshared stack size
               35750  page reclaims
                   0  page faults
                   0  swaps
                   0  block input operations
                   0  block output operations
                   0  messages sent
                   0  messages received
                   0  signals received
                  55  voluntary context switches
              938736  involuntary context switches
        114957983162  instructions retired
        192027128118  cycles elapsed
            45723648  peak memory footprint

After changes

8.52 real        35.95 user        19.82 sys
            64073728  maximum resident set size
                   0  average shared memory size
                   0  average unshared data size
                   0  average unshared stack size
               38685  page reclaims
                   0  page faults
                   0  swaps
                   0  block input operations
                   0  block output operations
                   0  messages sent
                   0  messages received
                   0  signals received
                  55  voluntary context switches
              989654  involuntary context switches
        108821228655  instructions retired
        182934096805  cycles elapsed
            57688064  peak memory footprint

from changes.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

So in terms of performance...not that different. JSONDecoder is known to be pretty slow in general (for a json decoder) so I guess this shouldn't surprise me. Also, Codable may be the slowest thing in this process

from changes.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

Benchmark code

import Files
import Foundation
import Yams
import Version
struct Temp: ParsableCommand {
  static var configuration = CommandConfiguration(
    commandName: "temp",
    abstract: ""
  )

  func run() throws {
    let loadedConfig = try ConfigurationLoader().load()
    guard let workingFolder = try File(path: loadedConfig.path).parent else {
      throw ChangesError("Could not find folder of changes config.")
    }

    let releasesFolder = try workingFolder.createSubfolderIfNeeded(
      at: ".changes/releases"
    )
    let encoder = JSONEncoder()
    for i in 0..<500 {
      let releaseFolder = try releasesFolder.createSubfolderIfNeeded(at: "1.0.\(i)")
      let info = ReleaseInfo(version: try! Version("1.0.\(i)"), createdAtDate: Date())
      let infoData = try encoder.encode(info)
      try releaseFolder.createFile(named: "info.json").write(infoData)
      let subfolder = try releaseFolder.createSubfolderIfNeeded(at: "entries")
      for _ in 0..<100 {
        let entry = ChangelogEntry(
          tags: ["Added", "Removed"],
          description: "This is a description",
          createdAtDate: Date()
        )

        let output = try encoder.encode(entry)
        try subfolder.createFile(named: "\(UUID().uuidString).json").write(output)
      }
    }
  }
}

from changes.

ScottRobbins avatar ScottRobbins commented on August 19, 2024

Tried to use ikigajson for fun to see if it'd speed it up but it just crashed.

from changes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.