Advertisement
BlackSack

Log analyse v2

Jun 19th, 2012
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 7.70 KB | None | 0 0
  1.  
  2. fclose('all')
  3. clc
  4. clear
  5.  
  6. logfile = fopen('C:\Users\Tom\Dropbox\myscript\log.txt');
  7.  
  8. linenum=1;
  9. nocell =0;
  10. yescell=0;
  11. deaths =0;
  12. repairs =0;
  13. sellevent=0;
  14. stashed=0;
  15. sold=0;
  16. stashfull=0;
  17. stashfullboth=0;
  18. loggedout=0;
  19. cellarwalkfail=0;
  20. cellarwalkfaildeath=0;
  21. failcorrected=0;
  22.  
  23. gaps=0;
  24.  
  25. tesstimes=[];
  26. runtimes=[];
  27. sellvalues=[];
  28. loot = [];
  29. repairvalues=[];
  30. logtimes=[];
  31. cellfindpoint=[0,0,0,0,0,0,0,0];
  32. cellfindpointfail=[0,0,0,0,0,0,0,0];
  33. gaptime=0;
  34. lastline='';
  35.  
  36. while ~feof(logfile)
  37.     thisline = fgetl(logfile);
  38.    
  39.     ltime =  thisline(1:19);
  40.     ltimenum =  datenum(ltime );
  41.     if linenum == 1, lasttime = ltimenum; end
  42.     thisline=lower(thisline(22:end));
  43.    
  44.     linerec = false;
  45.     if findstr(thisline,'oncellar recovery success'), failcorrected=failcorrected+1;linerec = true; end
  46.     if findstr(thisline,'oncellar recovery failure'), linerec = true; end
  47.     if findstr(thisline,'no cell'), nocell=nocell+1;linerec = true; end
  48.     if findstr(thisline,'died'), deaths=deaths+1;linerec = true;end
  49.     if findstr(thisline,'sell'), sellevent=sellevent+1;linerec = true;end
  50.     if length(thisline) >15 && strcmp('stash full using',thisline(1:16)), stashfull=stashfull+1;linerec = true;end
  51.     if strcmp('stash full',thisline), stashfull=stashfull+1;linerec = true;end
  52.     if length(thisline) >14 && strcmp('stash full both',thisline(1:15)), stashfullboth=stashfullboth+1;linerec = true;end
  53.     if findstr(thisline,'logged'), loggedout=loggedout+1;linerec = true;end
  54.     if findstr(thisline,'didnt end up')
  55.         cellarwalkfail=cellarwalkfail+1;
  56.         linerec = true;
  57.         cellfindpointfail(lastfind)=cellfindpointfail(lastfind)+1;
  58.     end
  59.     if findstr(thisline,'died') & findstr(lastline,'didnt end up')
  60.         cellarwalkfaildeath=cellarwalkfaildeath+1;
  61.         linerec = true;
  62.     end
  63.  
  64.     if findstr(thisline,'gold')
  65.         yescell=yescell+1;
  66.         linerec = true;
  67.         thisloot = textscan(thisline,'gold: %d, gold delt: %d, items: %d, gems: %d, books: %d, potions: %d, goldpick: %d');
  68.         try
  69.             loot=[loot; double(cell2mat(thisloot))];
  70.         catch
  71.             %disp(thisline)
  72.         end
  73.     end
  74.    
  75.     if findstr(thisline,'tesseract')
  76.         linerec = true;
  77.         thisloot = textscan(thisline,'tesseract time: %d');
  78.         if ~isempty(thisloot)
  79.             tesstimes=[tesstimes;double(cell2mat(thisloot(1)))];
  80.         end
  81.     end
  82.    
  83.     if findstr(thisline,'cellar found')
  84.         linerec = true;
  85.         thisloot = textscan(thisline,'cellar found at: %d');
  86.         if ~isempty(thisloot)
  87.             cellfindpoint(cell2mat(thisloot(1)))=cellfindpoint(cell2mat(thisloot(1)))+1;
  88.             lastfind=cell2mat(thisloot(1));
  89.         end
  90.     end
  91.    
  92.     if findstr(thisline,'sold')
  93.         linerec = true;
  94.         thisloot = textscan(thisline,'sold items: %d, sold value: %d');
  95.         if ~isempty(thisloot)
  96.             sold=sold+double(cell2mat(thisloot(1)));
  97.            
  98.             sellvalues=[sellvalues;double(cell2mat(thisloot(2)))];
  99.         end
  100.     end    
  101.    
  102.     if findstr(thisline,'repair cost')
  103.         linerec = true;
  104.         thisloot = textscan(thisline,'repair cost: %d');
  105.         repairs=repairs+1;
  106.         if ~isempty(thisloot)
  107.             repairvalues=[repairvalues;double(cell2mat(thisloot(1)))];
  108.         end
  109.     end    
  110.    
  111.    if findstr(thisline,'last runtime')
  112.         linerec = true;
  113.         thisloot = textscan(thisline,'last runtime: %f');
  114.         if ~isempty(thisloot)
  115.             runtimes=[runtimes;double(cell2mat(thisloot(1)))];
  116.         end
  117.     end    
  118.    
  119.     if findstr(thisline,'stash') & linerec == false
  120.         linerec = true;
  121.         thisloot = textscan(thisline,'stashed items: %d');
  122.         if ~isempty(thisloot)
  123.             stashed=stashed+double(cell2mat(thisloot));
  124.         end
  125.     end
  126.    
  127.     if ~linerec
  128.         disp(thisline)
  129.     end
  130.    
  131.     timed = ltimenum-lasttime;
  132.     [~, ~, ~, ~, M, ~] = datevec(timed);
  133.    
  134.     logtimes(linenum) = ltimenum;
  135.    
  136.     if M>2
  137.         % disp(datestr(timed,'HH:MM:SS'))
  138.         gaps=gaps+1;
  139.         gaptime=gaptime+timed;
  140.     end
  141.    
  142.     lasttime = ltimenum;
  143.     lastline = thisline;
  144.     linenum=linenum+1;
  145. end
  146.  
  147. totalruns = yescell+nocell;
  148.  
  149. entiretime = logtimes(end)-logtimes(1)-gaptime;
  150. [~, ~, ~, H, M, S] = datevec(entiretime);
  151. totalhours = H+(M/60)+(S/3600);
  152.  
  153. totalgold = loot(end,1)-loot(1,1);
  154. validgold=abs(loot(:,2)) < 20000 ;
  155. avggold=mean(loot( validgold ,2));
  156.  
  157. sellvalues = sellvalues( sellvalues < 30000 & sellvalues > 300);
  158.  
  159. avgsellval = mean(sellvalues);
  160. totalsell = sum(sellvalues);
  161.  
  162. alttotal = sum(loot( validgold ,2)) + (yescell-sum(validgold))*avggold + totalsell-sum(repairvalues);
  163.  
  164.  
  165. pickfreq = cellfindpoint./sum(cellfindpoint) * 100;
  166. failfreq = cellfindpointfail./sum(cellfindpointfail) * 100;
  167.  
  168. fprintf('\n')
  169. fprintf('Log Duration: %s, Gaps: %d, Totaling: %s\n\n',datestr(entiretime,'HH:MM:SS'),gaps,datestr(gaptime,'HH:MM:SS'))
  170. fprintf('Gold total: %d, Per Hour: %.2f, Per Trip: %.2f\n',floor(alttotal),alttotal/totalhours,avggold)
  171. %fprintf('Gold total: %d, Per Hour: %.2f, Per Trip: %.2f\n',totalgold,totalgold/totalhours,avggold)
  172. fprintf('Items total: %d, Per Hour: %.2f, Per Trip: %.2f, Chance %.2f%%\n',sum(loot(:,3)),sum(loot(:,3))/totalhours,mean(loot(:,3)),(1-(sum(loot(:,3)==0)/length(loot)))*100)
  173. fprintf('Gems total: %d, Per Hour: %.2f, Per Trip: %.2f, Chance %.2f%%\n',sum(loot(:,4)),sum(loot(:,4))/totalhours,mean(loot(:,4)),(1-(sum(loot(:,4)==0)/length(loot)))*100)
  174. fprintf('Books total: %d, Per Hour: %.2f, Per Trip: %.2f, Chance %.2f%%\n',sum(loot(:,5)),sum(loot(:,5))/totalhours,mean(loot(:,5)),(1-(sum(loot(:,5)==0)/length(loot)))*100)
  175. %fprintf('Potions total: %d, Per Hour: %.2f, Per Trip: %.2f, Chance %.2f%%\n',sum(loot(:,6)),sum(loot(:,6))/totalhours,mean(loot(:,6)),(1-(sum(loot(:,6)==0)/length(loot)))*100)
  176. %fprintf('GoldPick total: %d, Per Hour: %.2f, Per Trip: %.2f, Chance %.2f%%\n',sum(loot(:,7)),sum(loot(:,7))/totalhours,mean(loot(:,7)),(1-(sum(loot(:,7)==0)/length(loot)))*100)
  177.  
  178. fprintf('\nCellar frequency (success/total runs): %d/%d: %.2f%%\n',yescell,totalruns,yescell/totalruns*100)
  179. fprintf('Trips per hour: Total: %.2f, Success: %.2f, Fail %.2f\n',(totalruns)/totalhours,yescell/totalhours,nocell/totalhours)
  180. fprintf('Avg Runtime: %.2fs, Success: %.2fs, Fail: %.2fs, Vend: %.2fs\n\n',mean(runtimes),mean(runtimes(runtimes>25 & runtimes < 50)),mean(runtimes(runtimes < 25)),mean(runtimes(runtimes > 50)))
  181.  
  182.  
  183. fprintf('Repairs total: %d, Per Hour: %.2f, Cost: %d \n',repairs,repairs/totalhours,sum(repairvalues))
  184. fprintf('Deaths total: %d, Per Hour: %.2f\n',deaths,deaths/totalhours)
  185. fprintf('Sold total: %d, Per Hour: %.2f\n',sold,sold/totalhours)
  186. fprintf('Stashed total: %d, Per Hour: %.2f\n',stashed,stashed/totalhours)
  187. fprintf('Stash full events: First tab %d, Both tabs: %d\n',stashfull,stashfullboth)
  188. fprintf('Logged out events: %d\n',loggedout)
  189. fprintf('Failed runs: %d, Due to death: %d, Corrected with fix: %d\n',cellarwalkfail,cellarwalkfaildeath,failcorrected)
  190. fprintf('Detect Freq: p1: %.1f%%, p2: %.1f%%, p3: %.1f%%, p4: %.1f%%\n',pickfreq(1),pickfreq(2),pickfreq(3),pickfreq(4))
  191. %fprintf('Detect Freq: p5: %.1f%%, p6: %.1f%%, p7: %.1f%%, p8: %.1f%%\n',pickfreq(5),pickfreq(6),pickfreq(7),pickfreq(8))
  192. %fprintf('Fail Freq: p1: %.1f%%, p2: %.1f%%, p3: %.1f%%, p4: %.1f%%\n',failfreq(1),failfreq(2),failfreq(3),failfreq(4))
  193. %fprintf('Fail Freq: p5: %.1f%%, p6: %.1f%%, p7: %.1f%%, p8: %.1f%%\n',failfreq(5),failfreq(6),failfreq(7),failfreq(8))
  194.  
  195.  
  196. fprintf('\nTotal sold value: %d, Avg sell value: %.2f, Avg Item value: %.2f\n',totalsell,avgsellval,totalsell/sold)
  197. %fprintf('Tesseract mean: %.2fms, max: %.2fms min: %.2fms\n',mean(tesstimes),max(tesstimes),min(tesstimes))
  198.  
  199. fclose(logfile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement