Project

General

Profile

Bug #1450 » mentat.message.query.mongo.pl

Skript pro otestování vrstvy Mentat::Message::Query::Mongo - Jan Mach, 06/24/2014 10:18 AM

 
1
#!/usr/bin/perl -T
2

    
3
use strict;
4
use warnings;
5

    
6
use Time::HiRes qw( time );
7
use Value::Convertor;
8
use Mentat::Message::Storage::Mongo;
9
use Mentat::Message::Convertor::Mongo;
10
use Mentat::Message::Filter::Factory;
11
use Mentat::Message::Query::Mongo;
12

    
13
my $storage  = Mentat::Message::Query::Mongo->new(Mentat::Message::Convertor::Mongo->new(), Mentat::Message::Storage::Mongo->new());
14
my $ffactory = Mentat::Message::Filter::Factory->new_from_file('/etc/mentat/filter-grammar.conf');
15
my $filter   = $ffactory->filter_from_string('Alert/Source/Node/Address/ipv4/min ge 158.196.158.0 and Alert/Source/Node/Address/ipv4/max le 158.196.158.255 and Alert/Classification/@text eq "Webatack"');
16
my ($results, $count);
17

    
18
my $start = time;
19

    
20
################################################################################
21
# OPTION A
22
################################################################################
23

    
24
($results, $count) = $storage->query($filter);
25

    
26
################################################################################
27
my $end = time;
28
print STDERR "DURATION: ".($end-$start).", COUNT: $count\n";
29

    
(2-2/8)