view 02.pl @ 1:c32b619844ba default tip

add eview.go.
author pyon@macmini
date Sun, 17 Sep 2017 14:33:27 +0900
parents 43e580fa4719
children
line wrap: on
line source

#                      Last Change: 2017-09-04 Mon 21:39:25.
#  

use v5.10;
use utf8;
use Inline C;
use Benchmark;

# read params from json

# read data
my ( @n, @date, @start, @highest, @lowest, $ma3, $ma7, $ma30 );
open my $f, '<', 'data';
while ( <$f> ) {
    chomp;
    my ( $nn, $dt, $st, $hi, $low, $en, $m3, $m7, $m30 ) = split;
    push @n,     $nn;
    push @date,  $dt;
    push @start, $st;
    push @end,   $en;
    push @ma3,   $m3;
    push @ma7,   $m7;
    push @ma30,  $m30;
}
close $f;

# L2
hoge( scalar @n, @n );

#timethese( 10000000, {
#Perl => sub { for ( 1..10 ) { $x = $_ * $_; } },
#C    => sub { pow_test(); }
#} );

__DATA__
__C__
#include <stdio.h>

int pow_test(){
    int j;
    for ( int i = 0; i < 100000; i++ ) {
        j = i * i;
    }
    return j;
}

int hoge( int n, char* nn[] ) {
    for ( int i=0; i<n; i++ ) {
        pritnf( "%04d -> %s\n", i,nn );
    }
    return 0;
}