Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test caching classids #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/main/java/opendota/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public class Entry {
public Integer towers_killed;
public Integer roshans_killed;
public Integer observers_placed;
public Integer draft_order;
public Boolean pick;
public Integer draft_active_team;
public Integer draft_extime0;
public Integer draft_extime1;
public Integer draft_order;
public Boolean pick;
public Integer draft_active_team;
public Integer draft_extime0;
public Integer draft_extime1;

public Entry() {
}
Expand Down Expand Up @@ -153,6 +153,9 @@ public UnknownItemFoundException(String message) {
private GreevilsGreedVisitor greevilsGreedVisitor;
private TrackVisitor trackVisitor;
private ArrayList<Boolean> isPlayerStartingItemsWritten;
private int obsClassId = -1;
private int senClassId = -1;
private long nanoCount = 0;

//Draft stage variable

Expand Down Expand Up @@ -723,8 +726,23 @@ public void processEntity(Context ctx, Entity e, boolean entityLeft)
//CDOTA_NPC_Observer_Ward_TrueSight
//s1 "DT_DOTA_NPC_Observer_Ward"
//s1 "DT_DOTA_NPC_Observer_Ward_TrueSight"
boolean isObserver = e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward");
boolean isSentry = e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward_TrueSight");

// Cache the class IDs to avoid repeated string comparisons
int entityClassId = e.getDtClass().getClassId();
if (obsClassId == -1 && e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward")) {
obsClassId = entityClassId;
}
else if (senClassId == -1 && e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward_TrueSight")) {
senClassId = entityClassId;
}

long start = System.nanoTime();
boolean isObserver = entityClassId == obsClassId;
boolean isSentry = entityClassId == senClassId;
long end = System.nanoTime();
nanoCount += (end - start);
System.err.println(nanoCount);

if (isObserver || isSentry) {
//System.err.println(e);
Entry entry = new Entry(time);
Expand Down