mapbox-java
mapbox-java copied to clipboard
mapbox cost too much cpu
I overwrite the code like here:
public static boolean inRing(PointCustom pt, List<PointCustom> pointCustomList) {
boolean isInside = false;
for (int i = 0, j = pointCustomList.size() - 1; i < pointCustomList.size(); j = i++) {
double xi = pointCustomList.get(i).getLongitude();
double yi = pointCustomList.get(i).getLatitude();
double xj = pointCustomList.get(j).getLongitude();
double yj = pointCustomList.get(j).getLatitude();
boolean intersect = (
(yi > pt.getLatitude()) != (yj > pt.getLatitude()))
&& (pt.getLongitude() < (xj - xi) * (pt.getLatitude() - yi) / (yj - yi) + xi);
if (intersect) {
isInside = !isInside;
}
}
return isInside;
}
but i run it on the production.and find that the cpu of server cost too much ,200% CPU is consumed frequently when send 100 requests per second. My demand is to locate in the longitude and latitude data of 100000 cities through longitude and latitude。 And the args of varible : pointCustomList storage 100000+ CityInfo object. What problem can reduce the cost of CPU?