BTW, when you present data, please use <code>..</code> tags.
At this point, I didn't spend time worrying about how to improve your code that generates the 2 arrays. Before doing that, I would like to understand the end objective.
To try to understand the requirements, I wrote some simple code to replicate your @array and @array1. Then I reduced those arrays down to just the last part of the line that includes the 'multi_clk_chk:' stuff. I take it that only the stuff after 'multi_clk_chk:' matters?
See below and please explain what a comparison between Data Set A and Data Set B would be?
I suppose that these log files contain many records? Of which you are just showing one of each?
A first step might be to figure how to figure out how to select a record from X and a record from Y?
The difference in the T values seems to be what you really want?
It could be that a hash table is the right kind of data structure for each record? text before the T value as the key and T number as the value? Would order matter in the report?
I'm sure you will get lots of interesting implementation ideas if you can explain the requirements better.stuff before the T value => T value A: MTI Clock is being generated correctly ; => T=1102377 B: MTI Clock is being generated correctly ; => T=1092605 perhaps result: MTI Clock is being generated correctly ; T=1102377 T=1092605
Update: Please think about how you want the results to be presented to the user. General file compares can generate some confusing looking stuff. A good UI can be important. For example I am working on a feature request on a different project.. I understood instantly how to calculate the new desired result (the math was easy)...but, I spent an hour thinking about how to present this new data to the user in way that was not confusing and so that they'd understand what this information meant.
Another Update: I went ahead and hacked in some additional code for the "use a hash for comparison" idea. Still not sure what the OP wants, but this might be useful. No consideration for efficiency was made - that can be optimized later once the problem is understood.
#!/usr/bin/perl; use strict; use warnings; use Data::Dump qw(pp); # initialize @array and @array1 to what the OP describes as his curren +t "output"..... my @array =<<'EOF' =~ m/(^.*\n)/mg; INFO @576892 mti_clk_chk: run_stimulus called; T=576892 INFO @1102266 PHResourceLayer_Z4: mti_clk_chk:################ start o +f test ################ ; T=1102266 INFO @1102334 PHResourceLayer_Z4: mti_clk_chk:Checking the period of M +TI, MTI10 clk from SV; T=1102334 INFO @1102372 mti_clk_chk: Checking period of MTI CLk; T=1102372 INFO @1102377 mti_clk_chk: Period value of MTI Clock: 3.125000 ns; T=1 +102377 INFO @1102377 mti_clk_chk: MTI Clock is being generated correctly ; T= +1102377 INFO @1102377 mti_clk_chk: Checking period of MTI10 CLk; T=1102377 INFO @1102418 mti_clk_chk: Period value of MTI10 Clock: 31.250000 ns; +T=1102418 INFO @1102418 mti_clk_chk: MTI10 Clock is being generated correctly ; +T=1102418 INFO @1102717 PHResourceLayer_Z4: mti_clk_chk: All clock period Checki +ng done; T=1102717 INFO @1148661 mti_clk_chk: C-Code exit execution. code=<aa>; T=1148661 INFO @1148661 mti_clk_chk: ************************ SV END************ +******** ; T=1148661 EOF my @array1 =<<'EOF2' =~ m/(^.*\n)/mg; UVM_INFO @0 reporter testbench.top_level_module.\mti_clk_chk::main : M +TI_CLK_CHK_STIM Started .....; T=0 UVM_INFO @0 reporter testbench.top_level_module.\mti_clk_chk::main : r +un_stimulus called; T=0 UVM_INFO @1092507 reporter Z4_COREA: mti_clk_chk: ################ sta +rt of test ################ ; T=1092507 UVM_INFO @1092563 reporter Z4_COREA: mti_clk_chk: Checking the period +of MTI, MTI10 clk from SV; T=1092563 UVM_INFO @1092598 reporter testbench.top_level_module.\mti_clk_chk::ma +in : Checking period of MTI CLk; T=1092598 UVM_INFO @1092605 /proj/rru2_verif/usr/Tilak/SV_UVM/testbench/data_ipd +ss/v_ms_mti_stim_vip/testbench/classes_v/mti_clk_chk.sv(147) uvm_test +_top.default_env.default_sequencer100@@mti_clk_chk mti_clk_chk:INFO: +Period value of MTI Clock: 3.125000 ns; T=1092605 UVM_INFO @1092605 reporter testbench.top_level_module.\mti_clk_chk::ma +in : MTI Clock is being generated correctly ; T=1092605 UVM_INFO @1092605 reporter testbench.top_level_module.\mti_clk_chk::ma +in : Checking period of MTI10 CLk; T=1092605 UVM_INFO @1092655 /proj/rru2_verif/usr/Tilak/SV_UVM/testbench/data_ipd +ss/v_ms_mti_stim_vip/testbench/classes_v/mti_clk_chk.sv(165) uvm_test +_top.default_env.default_sequencer100@@mti_clk_chk mti_clk_chk:INFO: +Period value of MTI10 Clock: 31.250000 ns; T=1092655 UVM_INFO @1092655 reporter testbench.top_level_module.\mti_clk_chk::ma +in : MTI10 Clock is being generated correctly ; T=1092655 UVM_INFO @1092850 reporter Z4_COREA: mti_clk_chk: All clock period Che +cking done; T=1092850 UVM_INFO @1092886 /proj/rru2_verif/usr/Tilak/SV_UVM/testbench/data_ipd +ss/v_ms_mti_stim_vip/testbench/classes_v/mti_clk_chk.sv(186) uvm_test +_top.default_env.default_sequencer100@@mti_clk_chk mti_clk_chk:INFO: +************************ SV END******************** ; T=1092886 EOF2 # evidently all that matters is stuff after the 'mti_clk_chk:' string # so remove all before that critical stuff @array = map{/^.*(mti_clk_chk:.*\n)/;$1;}@array; @array1 = map{/^.*(mti_clk_chk:.*\n)/;$1;}@array1; ## just print these arrays out so that we can see how to ## compare them? my $n=1; foreach (@array) {print "A$n) ",$_; $n++} print "===============================\n"; $n=1; foreach (@array1) {print "B$n) ",$_; $n++} ## Make hash tables of the 2 records ## regex could be better - not the point here.. just a quick demo of a +n approach.. my %A = map{/mti_clk_chk:(?::main :|INFO:)?\s*(.*).*\s*T=(\d+)$/;$1 => + $2}@array; my %B = map{/mti_clk_chk:(?::main :|INFO:)?\s*(.*).*\s*T=(\d+)$/;$1 => + $2}@array1; #print only common values in sequential order of file A print "\n********************************************\n"; print "Common Text descriptions with A and B T values:\n"; print "********************************************\n"; foreach my $mti (map{/mti_clk_chk:(?::main :|INFO:)?\s*(.*).*\s*T=(\d+ +)$/;$1}@array) { if (exists $B{$mti}) { print "$mti T(a)=$A{$mti} T(b)=$B{$mti}\n"; } } __END__ A1) mti_clk_chk: run_stimulus called; T=576892 A2) mti_clk_chk:################ start of test ################ ; T=11 +02266 A3) mti_clk_chk:Checking the period of MTI, MTI10 clk from SV; T=11023 +34 A4) mti_clk_chk: Checking period of MTI CLk; T=1102372 A5) mti_clk_chk: Period value of MTI Clock: 3.125000 ns; T=1102377 A6) mti_clk_chk: MTI Clock is being generated correctly ; T=1102377 A7) mti_clk_chk: Checking period of MTI10 CLk; T=1102377 A8) mti_clk_chk: Period value of MTI10 Clock: 31.250000 ns; T=1102418 A9) mti_clk_chk: MTI10 Clock is being generated correctly ; T=1102418 A10) mti_clk_chk: All clock period Checking done; T=1102717 A11) mti_clk_chk: C-Code exit execution. code=<aa>; T=1148661 A12) mti_clk_chk: ************************ SV END******************** +; T=1148661 =============================== B1) mti_clk_chk::main : MTI_CLK_CHK_STIM Started .....; T=0 B2) mti_clk_chk::main : run_stimulus called; T=0 B3) mti_clk_chk: ################ start of test ################ ; T=1 +092507 B4) mti_clk_chk: Checking the period of MTI, MTI10 clk from SV; T=1092 +563 B5) mti_clk_chk::main : Checking period of MTI CLk; T=1092598 B6) mti_clk_chk:INFO: Period value of MTI Clock: 3.125000 ns; T=109260 +5 B7) mti_clk_chk::main : MTI Clock is being generated correctly ; T=109 +2605 B8) mti_clk_chk::main : Checking period of MTI10 CLk; T=1092605 B9) mti_clk_chk:INFO: Period value of MTI10 Clock: 31.250000 ns; T=109 +2655 B10) mti_clk_chk::main : MTI10 Clock is being generated correctly ; T= +1092655 B11) mti_clk_chk: All clock period Checking done; T=1092850 B12) mti_clk_chk:INFO: ************************ SV END**************** +**** ; T=1092886 # Some of the issues involved in the comparison between sets: # Line B1 doesn't exist in set A # line A11 doesn't exist in set B # one plausible way to present the output? ******************************************** Common Text descriptions with A and B T values: ******************************************** run_stimulus called; T(a)=576892 T(b)=0 ################ start of test ################ ; T(a)=1102266 T(b)=1 +092507 Checking the period of MTI, MTI10 clk from SV; T(a)=1102334 T(b)=1092 +563 Checking period of MTI CLk; T(a)=1102372 T(b)=1092598 Period value of MTI Clock: 3.125000 ns; T(a)=1102377 T(b)=1092605 MTI Clock is being generated correctly ; T(a)=1102377 T(b)=1092605 Checking period of MTI10 CLk; T(a)=1102377 T(b)=1092605 Period value of MTI10 Clock: 31.250000 ns; T(a)=1102418 T(b)=1092655 MTI10 Clock is being generated correctly ; T(a)=1102418 T(b)=1092655 All clock period Checking done; T(a)=1102717 T(b)=1092850 ************************ SV END******************** ; T(a)=1148661 T( +b)=1092886
In reply to Re: Compare two log files line by line containing a keyword
by Marshall
in thread Compare two log files line by line containing a keyword
by rahu_6697
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |