<commit_before># inspired by https://github.com/brendangregg/FlameGraph
require 'base64'

class Flamegraph::Renderer
  def initialize(stacks)
    @stacks = stacks
  end

  def graph_html(embed_resources)
    body = read('flamegraph.html')
    body.sub! "/**INCLUDES**/",
      if embed_resources
        embed("jquery.min.js","d3.min.js","lodash.min.js")
      else
        '<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.0.8/d3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>'
      end

    body.sub!("/**DATA**/", ::JSON.generate(graph_data));<commit_msg>Deprecated protocol-relative URLs for CloudFlare CDN assets, since breaks on file:// URLs<commit_after># inspired by https://github.com/brendangregg/FlameGraph
require 'base64'

class Flamegraph::Renderer
  def initialize(stacks)
    @stacks = stacks
  end

  def graph_html(embed_resources)
    body = read('flamegraph.html')
    body.sub! "/**INCLUDES**/",
      if embed_resources
        embed("jquery.min.js","d3.min.js","lodash.min.js")
      else
        '<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.0.8/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>'
      end

    body.sub!("/**DATA**/", ::JSON.generate(graph_data));
{'fraction_non_alphanumeric': 0.18933333333333333, 'fraction_numerical': 0.018666666666666668, 'mean_word_length': 3.6470588235294117, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1974063', 'n_tokens_mistral': 575, 'n_tokens_neox': 545, 'n_words': 74}