Code Monkey home page Code Monkey logo

nimbler-path's Introduction

NimblerPath

Gem Version Build Status

This gem replaces most-used Pathname class ruby methods with much faster counterparts written in Nim.
Use for hassle-free, dependency-free speed gains, primarily in Rails projects.

Supported Platforms

As of version 0.9.0 the gem will support 64bit versions of Linux and Mac.
Support for Windows is a hassle due to differing path separator, among other things.
Open an issue or PR if other OS support is needed.

Dependencies

ruby ">= 2.1.10" # for required keyword arguments

Installation

gem 'nimbler_path', require: false
# in an initializer like /config/initializers/nimbler_path.rb
require 'nimbler_path'
require 'nimbler_path/monkeypatch'

NimblerPath.apply_monkeypatch!(verbose: true)

Discussion

faster_path identifies these Pathname methods as taking the most execution time.

Pathname#chop_basename(path) @ https://goo.gl/9Lk1N9 called 24456 times, 25% of execution time alone
Pathname#to_s (implicit C definition?) called 29172 times.
Pathname#<=> (implicit C definition?) called 24963 times.
Pathname#initialize in C @ https://goo.gl/dqB8R2 called 23103 times.
Pathname#absolute? @ https://goo.gl/5aXYxw called 4840 times.
Pathname#+ @ https://goo.gl/W7biJu called 4606 times.
Pathname#plus @ https://goo.gl/eRxLYt called 4606 times.
Pathname#join @ https://goo.gl/9NzWRt called 4600 times.
Pathname#extname in C @ https://goo.gl/uANaNu called 4291 times.
Pathname#hash in C @ https://goo.gl/6eVS1x called 4207 times.
Pathname#to_path in C @ https://goo.gl/EX7Cfx called 2706 times.
Pathname#directory? in C @ https://goo.gl/PbMbjY called 2396 times.
Pathname#entries in C @ https://goo.gl/8ALU6R called 966 times.

Ignoring methods already implemented in C leaves us with:

Pathname#chop_basename(path) @ https://goo.gl/9Lk1N9 called 24456 times, 25% of execution time alone

Pathname#+ @ https://goo.gl/W7biJu called 4606 times.
Pathname#plus @ https://goo.gl/eRxLYt called 4606 times.
Pathname#join @ https://goo.gl/9NzWRt called 4600 times.
Pathname#absolute? @ https://goo.gl/5aXYxw called 4840 times.
# flipside
Pathname#relative? @ https://goo.gl/QK4PCs

This project, at most, aims to provide performant variants for those six methods.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Epigene/nimbler_path. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Ruby development setup

  1. Clone the project with git clone [email protected]:Epigene/nimbler-path.git
  2. Make sure you are using Ruby v2.1.10
  3. Bundle
  4. Run naive gem-code tests with ruby test/nimbler_path_test.rb
  5. Run the tests in included Ruby Spec Suite with mspec/bin/mspec spec (Specs affected by this gem are run with mspec/bin/mspec spec/library/pathname.
  6. Work on feature, commit and make a pull request 👏
  7. See how benchmarks add up with ruby test/nimbler_path_benchmarks.rb

Please note that this project includes a snapshot of the Ruby Spec Suite project under spec and a snapshot of MSpec project under mspec.

__Nim development setup

  1. Make sure you are running nim ..
  2. See if compilation works ..
  3. Work on nim code changes..
  4. https://forum.nim-lang.org/t/3153

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the NimblerPath project’s codebases and issue trackers is expected to follow the code of conduct.

Inspired By

faster_path

nimbler-path's People

Contributors

epigene avatar

Watchers

James Cloos avatar

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.