Advertisement
Guest User

phez

a guest
Jul 14th, 2009
1,623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2. ini_set('memory_limit', '192M');
  3.  
  4. $filename_btrfs = 'btrfs_true.txt';
  5. $filename_reiser4 = 'reiser4_true.txt';
  6.  
  7. $data_btrfs = explode("\n", file_get_contents($filename_btrfs));
  8. $data_reiser4 = explode("\n", file_get_contents($filename_reiser4));
  9.  
  10. $count_btrfs = array();
  11. $count_reiser4 = array();
  12. $count_similar = array();
  13. $count_total = 0;
  14. $count_total_similar = 0;
  15.  
  16. for($i = 0; $i < count($data_btrfs); $i++)
  17. {
  18.   $pair = explode(' ', trim($data_btrfs[$i]));
  19.   $pair[1] = trim(preg_replace('/[^\w]/', '', $pair[1]));
  20.  
  21.   if(!empty($pair[1]))
  22.   {
  23.     if(isset($count_btrfs[$pair[1]]))
  24.     {
  25.       $count_btrfs[$pair[1]] += trim($pair[0]);
  26.     }
  27.     else
  28.     {
  29.       $count_btrfs[$pair[1]] = trim($pair[0]);
  30.     }
  31.   }
  32. }
  33.  
  34. for($i = 0; $i < count($data_reiser4); $i++)
  35. {
  36.   $pair = explode(' ', trim($data_reiser4[$i]));
  37.   $pair[1] = trim(preg_replace('/[^\w]/', '', $pair[1]));
  38.  
  39.   if(!empty($pair[1]))
  40.   {
  41.     if(isset($count_reiser4[$pair[1]]))
  42.     {
  43.       $count_reiser4[$pair[1]] += trim($pair[0]);
  44.     }
  45.     else
  46.     {
  47.       $count_reiser4[$pair[1]] = trim($pair[0]);
  48.     }
  49.   }
  50. }
  51.  
  52. for($i = 0; $i < count($data_btrfs); $i++)
  53. {
  54.         $pair = explode(' ', trim($data_btrfs[$i]));
  55.         $pair[1] = trim(preg_replace('/[^\w]/', '', $pair[1]));
  56.  
  57.         if(!empty($pair[1]))
  58.         {
  59.                 if(isset($count_reiser4[$pair[1]]))
  60.                 {
  61.                         if(isset($count_similar[$pair[1]]))
  62.                         {
  63.                                 $count_similar[$pair[1]] += $count_reiser4[$pair[1]] + $count_btrfs[$pair[1]];
  64.                         }
  65.                         else
  66.                         {
  67.                                 $count_similar[$pair[1]] = $count_reiser4[$pair[1]] + $count_btrfs[$pair[1]];
  68.                         }
  69.                 }
  70.         }
  71. }
  72.  
  73. $keys = array_keys($count_btrfs);
  74. for($i = 0; $i < count($keys); $i++)
  75. {
  76.         $count_total += $count_btrfs[$keys[$i]];
  77. }
  78.  
  79. $keys = array_keys($count_reiser4);
  80. for($i = 0; $i < count($keys); $i++)
  81. {
  82.         $count_total += $count_reiser4[$keys[$i]];
  83. }
  84.  
  85. $keys = array_keys($count_similar);
  86. for($i = 0; $i < count($keys); $i++)
  87. {
  88.         $count_total_similar += $count_similar[$keys[$i]];
  89. }
  90.  
  91. print(round($count_total_similar / $count_total * 100, 2));
  92. print("%\n");
  93.  
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement