<commit_before>#    This file is part of the RSP.
#
#    The RSP is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    The RSP is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with the RSP.  If not, see <http://www.gnu.org/licenses/>.
package RSP::Transaction;

use strict;
use warnings;
use JavaScript;

use Module::Load;
use Time::HiRes qw( gettimeofday tv_interval );
use File::Spec;
use Hash::Merge::Simple;

sub start {
  my $class = shift;
  my $req   = shift or die "no request provided";
  my $hints = shift || {};
  my $rt    = JavaScript::Runtime->new;
  my $cx    = $rt->create_context;

  $cx->set_version("1.7") if $cx->can("set_version");
#  if ( $cx->can("toggle_options") ) {
    print "WE ARE JITTING\n";
    $cx->toggle_options( "jit" );
#  }

  my $turi = URI->new('http://' . lc($req->header('Host')) . '/');

  my $self = { ops => 0, host => $turi->host, request => $req, context => $cx };
  bless $self => $class;

  $self->{hints} = $hints;

  $rt->set_interrupt_handler( sub {
    $self->{ops}++;
    return 1;
  } );

  $self->import_extensions();
  return $self;
}

sub host {
  my $self = shift;
  return $self->{host};
}

sub run {
  my $self = shift;
  my $func = shift || 'main';
  
  $self->profile('transaction');<commit_msg>try to set the js version and toggle the jitting on<commit_after>#    This file is part of the RSP.
#
#    The RSP is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    The RSP is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with the RSP.  If not, see <http://www.gnu.org/licenses/>.
package RSP::Transaction;

use strict;
use warnings;
use JavaScript;

use Module::Load;
use Time::HiRes qw( gettimeofday tv_interval );
use File::Spec;
use Hash::Merge::Simple;

sub start {
  my $class = shift;
  my $req   = shift or die "no request provided";
  my $hints = shift || {};
  ## allocate 3 megs of RAM to this...
  my $rt    = JavaScript::Runtime->new( ( 1024 ** 2 ) * 3 );
  my $cx    = $rt->create_context;

  ## try setting the version to 1.8..
  eval {
    $cx->set_version("1.8");
    $cx->toggle_options( "jit" );
  };
  my $turi = URI->new('http://' . lc($req->header('Host')) . '/');

  my $self = { ops => 0, host => $turi->host, request => $req, context => $cx };
  bless $self => $class;

  $self->{hints} = $hints;

  $rt->set_interrupt_handler( sub {
    $self->{ops}++;
    return 1;
  } );

  $self->import_extensions();
  return $self;
}

sub host {
  my $self = shift;
  return $self->{host};
}

sub run {
  my $self = shift;
  my $func = shift || 'main';
  
  $self->profile('transaction');
{'fraction_non_alphanumeric': 0.14130434782608695, 'fraction_numerical': 0.005434782608695652, 'mean_word_length': 3.1880239520958082, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7020939', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1134, 'n_words': 424}