Sponsored Content
Top Forums Shell Programming and Scripting Measure thread execution (in C, unix) Post 302507643 by rob171171 on Thursday 24th of March 2011 11:28:17 AM
Old 03-24-2011
see contents of hash.pl

Code:
#!/usr/bin/perl

##############################################################

#use strict;
use warnings;

my $hash = ();

sub trim($)
{
        my $string = shift;
        $string =~ s/^\s+//;
        $string =~ s/\s+$//;
        return $string;
}


#$target_filename = shift;
#open(SESAME,"<$target_filename") || die "Cannot open file for output\n";

while(<>){
        @fields = split(/\|/, $_);
        $msisdn = trim($fields[2]);
        $APNREQ = trim($fields[4]); if ($APNREQ eq "") { $APNREQ = "NULL"; }
        $APNSUB = trim($fields[5]);
        if($msisdn =~ /^353/){

        $msisdn .= "-$APNREQ";
        $msisdn .= "-$APNSUB";
        if (exists $hash{$msisdn}) {
        $num = $hash{$msisdn};
        $num++;
        delete $hash{$msisdn};
        $hash{ $msisdn } = $num;
        } else {

        $hash{ $msisdn } = '1';

        }

    }

}

while ( my ($key, $value) = each(%hash) ) {

@apns = split(/\-/, $key);

#print "$value " ."|" . "$apns[0]" . "|" . "$apns[1]" . "|" . "$apns[2]\n";
print "$value " ."|" ."$apns[0]" . "|" . "$apns[1]\n";

}


Last edited by Franklin52; 03-25-2011 at 04:01 AM.. Reason: Please use code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

CPU load unit of measure?

If unix says my cpu load is 2.15 exactly what does that mean? --Jason (1 Reply)
Discussion started by: Mac J
1 Replies

2. Forum Support Area for Unregistered Users & Account Problems

How to post a new thread (Regarding Unix related doubts) in Unix Forums

How to post a new thread (Regarding Unix related doubts) in Unix Forums. I registered my id but I am unable to post my Questions to Forum. Thanks & Regards, indusri (1 Reply)
Discussion started by: indusri
1 Replies

3. Shell Programming and Scripting

Is there a command to measure compile speed?

Hello Ive written 2 programs in shell and I need to compare their speed (Compile) against one another. what methods could I go about doing this? Is there a feature in shell do accommodate this? (2 Replies)
Discussion started by: Darklight
2 Replies

4. UNIX for Advanced & Expert Users

How to measure g++ performance?

I am working on an application with some rather interesting build performance issues. If we build on Solaris/Linux x86/AMD64 the build is rather fast, but it takes more than five times as long on our Solaris Sparc servers (single-threaded builds on the workstations, but multi-threaded on the... (5 Replies)
Discussion started by: Elric of Grans
5 Replies

5. Solaris

What exactly does 'zpool iostat' measure?

hi there, i'd like to know what exactly zpool's iostat (-v) output measure, especially the writes. Is it only the writes to the ZIL or all writes (including commmits) to the disks? if anyone knows, that'd be helpful roti (1 Reply)
Discussion started by: rotunda
1 Replies

6. UNIX for Advanced & Expert Users

Implementing thread in UNIX

Hi For our load testing , we are using stubs (unix shell script) which send the response to the request coming from the application. As the unix stub is single threaded , it is responding to only one request whereas multiple requests come in parallely. I haven't worked on thread concepts... (5 Replies)
Discussion started by: jenanee
5 Replies

7. AIX

How to measure waiting time in run queue?

Hello guys, I am doing a performance analysis on one of our psystem. Most of time I am using Nmon analyser to do my trend graph. But I can't find any help with it. We are interesting in the time spend by tasks in Aix run queue. After looking the Aix documentation, I am pessimist to find any... (3 Replies)
Discussion started by: GiiGii
3 Replies

8. Solaris

How to measure IOPS?

Hi I have a system running solaris 10, and I intend to use a NetApp as its storage system. The application requires a throughput between the server and the storage 7000 disk IOPS (random IO sustained throughput with response time of 20 mili second and 16k block size). How to make sure that I... (6 Replies)
Discussion started by: fretagi
6 Replies

9. Shell Programming and Scripting

Python Thread Execution Issue . . .

Greetings! I set up a basic threading specimen which does the job:#!/usr/bin/python import threading class a(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): print("thread a finished") class b(threading.Thread): ... (0 Replies)
Discussion started by: LinQ
0 Replies
Tie::Memoize(3pm)					 Perl Programmers Reference Guide					 Tie::Memoize(3pm)

NAME
Tie::Memoize - add data to hash when needed SYNOPSIS
require Tie::Memoize; tie %hash, 'Tie::Memoize', &fetch, # The rest is optional $DATA, &exists, {%ini_value}, {%ini_existence}; DESCRIPTION
This package allows a tied hash to autoload its values on the first access, and to use the cached value on the following accesses. Only read-accesses (via fetching the value or "exists") result in calls to the functions; the modify-accesses are performed as on a normal hash. The required arguments during "tie" are the hash, the package, and the reference to the "FETCH"ing function. The optional arguments are an arbitrary scalar $data, the reference to the "EXISTS" function, and initial values of the hash and of the existence cache. Both the "FETCH"ing function and the "EXISTS" functions have the same signature: the arguments are "$key, $data"; $data is the same value as given as argument during tie()ing. Both functions should return an empty list if the value does not exist. If "EXISTS" function is different from the "FETCH"ing function, it should return a TRUE value on success. The "FETCH"ing function should return the intended value if the key is valid. Inheriting from Tie::Memoize The structure of the tied() data is an array reference with elements 0: cache of known values 1: cache of known existence of keys 2: FETCH function 3: EXISTS function 4: $data The rest is for internal usage of this package. In particular, if TIEHASH is overwritten, it should call SUPER::TIEHASH. EXAMPLE
sub slurp { my ($key, $dir) = shift; open my $h, '<', "$dir/$key" or return; local $/; <$h> # slurp it all } sub exists { my ($key, $dir) = shift; return -f "$dir/$key" } tie %hash, 'Tie::Memoize', &slurp, $directory, &exists, { fake_file1 => $content1, fake_file2 => $content2 }, { pretend_does_not_exists => 0, known_to_exist => 1 }; This example treats the slightly modified contents of $directory as a hash. The modifications are that the keys fake_file1 and fake_file2 fetch values $content1 and $content2, and pretend_does_not_exists will never be accessed. Additionally, the existence of known_to_exist is never checked (so if it does not exists when its content is needed, the user of %hash may be confused). BUGS
FIRSTKEY and NEXTKEY methods go through the keys which were already read, not all the possible keys of the hash. AUTHOR
Ilya Zakharevich mailto:perl-module-hash-memoize@ilyaz.org <mailto:perl-module-hash-memoize@ilyaz.org>. perl v5.12.1 2010-04-26 Tie::Memoize(3pm)
All times are GMT -4. The time now is 09:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy