-
-
Notifications
You must be signed in to change notification settings - Fork 901
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,075 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
CONTENTS = <<~RUBY | ||
source 'https://rubygems.org' | ||
gemspec | ||
RUBY | ||
|
||
File.open('Gemfile', 'wb') { |f| f.puts CONTENTS } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Memory Profile | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
memory_profile: | ||
if: "!contains(github.event.commits[0].message, '[ci skip]')" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-ruby@v1 | ||
with: | ||
ruby-version: '2.7' | ||
- name: Set up Dependencies Cache | ||
uses: actions/cache@v1 | ||
with: | ||
path: vendor/bundle | ||
key: ubuntu-latest-gems | ||
restore-keys: | | ||
ubuntu-latest-gems- | ||
- name: Install dependencies | ||
run: | | ||
bundle config path vendor/bundle | ||
bundle install -j8 | ||
bundle exec rake gem:spec | ||
bundle exec ruby .github/workflows/actions/munge_gemfile.rb | ||
bundle install -j8 | ||
- name: Compile Nokogiri | ||
run: bundle exec rake compile | ||
- name: Memory Profile of parsing and serializing HTML Document | ||
run: bundle exec rake memprof:html_doc | ||
- name: Memory Profile of parsing and serializing HTML Document Fragment | ||
run: bundle exec rake memprof:html_doc_frag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :memprof do | ||
require "memory_profiler" | ||
module NokoMemProf | ||
def self.profile abs_path | ||
puts "\nTesting with Nokogiri v" + Nokogiri::VERSION.to_s | ||
puts | ||
contents = File.read abs_path | ||
MemoryProfiler.report do | ||
1000.times { yield contents } | ||
end.pretty_print(scale_bytes: true, normalize_paths: true) | ||
end | ||
end | ||
|
||
|
||
task :html_doc do | ||
require "nokogiri" | ||
|
||
abs_path = File.expand_path("../test/files/fixture.html", __dir__) | ||
NokoMemProf.profile(abs_path) do |contents| | ||
Nokogiri::HTML::Document.parse(contents).to_html | ||
end | ||
end | ||
|
||
task :html_doc_frag do | ||
require "nokogiri" | ||
|
||
abs_path = File.expand_path("../test/files/fixture_body.html", __dir__) | ||
NokoMemProf.profile(abs_path) do |contents| | ||
Nokogiri::HTML::DocumentFragment.parse(contents).to_html | ||
end | ||
end | ||
end |
Oops, something went wrong.