number of processors * 2.
357721
private void returnDocumentBuilderToPool(DocumentBuilder db) {
        try {
            db.reset();
            documentBuilderPool.offerFirst(db);
        } catch (UnsupportedOperationException e) {
            // document builders that don't support reset() can't be pooled
        }
    }
922788
def detect_number_of_cores():
    
    # Linux, Unix and MacOS:
    if hasattr(os, "sysconf"):
        if "SC_NPROCESSORS_ONLN" in os.sysconf_names:
            # Linux & Unix:
            ncpus = os.sysconf("SC_NPROCESSORS_ONLN")
            if isinstance(ncpus, int) and ncpus > 0:
                return ncpus
        else:  # OSX:
            return int(subprocess.check_output(["sysctl", "-n", "hw.ncpu"]))
    # Windows:
    try:
        ncpus = int(os.environ.get("NUMBER_OF_PROCESSORS", ""))
        if ncpus > 0:
            return ncpus
    except ValueError:
        pass
    return 1
1010246
public static int NextPowerOf2(int x) {
        --x;
        x |= x >> 1;
        x |= x >> 2;
        x |= x >> 4;
        x |= x >> 8;
        x |= x >> 16;
        return ++x;
    }
1289356
def cpuinfo():
    ''' 

    '''

    cpuinfo=OrderedDict()
    procinfo=OrderedDict()

    nprocs = 0
    with open('/proc/cpuinfo') as f:
        for line in f:
            if not line.strip():
                # end of one processor
                cpuinfo['proc%s' % nprocs] = procinfo
                nprocs=nprocs+1
                # Reset
                procinfo=OrderedDict()
            else:
                if len(line.split(':')) == 2:
                    procinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()
                else:
                    procinfo[line.split(':')[0].strip()] = ''
            
    return cpuinfo
3386
def _n_2(self):
        """"""
        return (self._f(3, 1) * self._f(2, 1) +
                self._f(3, 0) * self._f(1, 3) * self._f(2, 1) +
                self._f(3, 0) * self._f(2, 0) * self._f(1, 2))
1239796
private int trMedian5(int ISAd, int v1, int v2, int v3, int v4, int v5) {
        int t;
        if (SA[ISAd + SA[v2]] > SA[ISAd + SA[v3]]) {
            t = v2;
            v2 = v3;
            v3 = t;
        }
        if (SA[ISAd + SA[v4]] > SA[ISAd + SA[v5]]) {
            t = v4;
            v4 = v5;
            v5 = t;
        }
        if (SA[ISAd + SA[v2]] > SA[ISAd + SA[v4]]) {
            t = v2;
            v2 = v4;
            v4 = t;
            t = v3;
            v3 = v5;
            v5 = t;
        }
        if (SA[ISAd + SA[v1]] > SA[ISAd + SA[v3]]) {
            t = v1;
            v1 = v3;
            v3 = t;
        }
        if (SA[ISAd + SA[v1]] > SA[ISAd + SA[v4]]) {
            t = v1;
            v1 = v4;
            v4 = t;
            t = v3;
            v3 = v5;
            v5 = t;
        }
        if (SA[ISAd + SA[v3]] > SA[ISAd + SA[v4]]) {
            return v4;
        }
        return v3;
    }
184525
def num_devices(self):
        
        c_count = c_uint()
        _check_return(_NVML.get_function(
            "nvmlDeviceGetCount_v2")(byref(c_count)))
        return c_count.value
1219790
@Override
	public Processor newProcessor(Processor p) {
		AMRulesAggregatorProcessor oldProcessor = (AMRulesAggregatorProcessor) p;
		Builder builder = new Builder(oldProcessor);
		AMRulesAggregatorProcessor newProcessor = builder.build();
		newProcessor.resultStream = oldProcessor.resultStream;
		newProcessor.statisticsStream = oldProcessor.statisticsStream;
		return newProcessor;
	}
430376
private int ssPartition(int PA, int first, int last, int depth) {
        int a, b;// SA pointer
        int t;
        for (a = first - 1, b = last; ; ) {
            for (; (++a < b) && ((SA[PA + SA[a]] + depth) >= (SA[PA + SA[a] + 1] + 1)); ) {
                SA[a] = ~SA[a];
            }
            for (; (a < --b) && ((SA[PA + SA[b]] + depth) < (SA[PA + SA[b] + 1] + 1)); ) {
            }
            if (b <= a) {
                break;
            }
            t = ~SA[b];
            SA[b] = SA[a];
            SA[a] = t;
        }
        if (first < a) {
            SA[first] = ~SA[first];
        }
        return a;
    }
397026
public int[] Multi8p(int x, int y, int masc[][]) {
        //a b c
        //d e f
        //g h i
        int aR = getIntComponent0(x - 1, y - 1);
        int bR = getIntComponent0(x - 1, y);
        int cR = getIntComponent0(x - 1, y + 1);
        int aG = getIntComponent1(x - 1, y - 1);
        int bG = getIntComponent1(x - 1, y);
        int cG = getIntComponent1(x - 1, y + 1);
        int aB = getIntComponent2(x - 1, y - 1);
        int bB = getIntComponent2(x - 1, y);
        int cB = getIntComponent2(x - 1, y + 1);


        int dR = getIntComponent0(x, y - 1);
        int eR = getIntComponent0(x, y);
        int fR = getIntComponent0(x, y + 1);
        int dG = getIntComponent1(x, y - 1);
        int eG = getIntComponent1(x, y);
        int fG = getIntComponent1(x, y + 1);
        int dB = getIntComponent2(x, y - 1);
        int eB = getIntComponent2(x, y);
        int fB = getIntComponent2(x, y + 1);


        int gR = getIntComponent0(x + 1, y - 1);
        int hR = getIntComponent0(x + 1, y);
        int iR = getIntComponent0(x + 1, y + 1);
        int gG = getIntComponent1(x + 1, y - 1);
        int hG = getIntComponent1(x + 1, y);
        int iG = getIntComponent1(x + 1, y + 1);
        int gB = getIntComponent2(x + 1, y - 1);
        int hB = getIntComponent2(x + 1, y);
        int iB = getIntComponent2(x + 1, y + 1);

        int rgb[] = new int[3];

        rgb[0] = ((aR * masc[0][0]) + (bR * masc[0][1]) + (cR * masc[0][2]) +
                (dR * masc[1][0]) + (eR * masc[1][1]) + (fR * masc[1][2]) +
                (gR * masc[2][0]) + (hR * masc[2][1]) + (iR * masc[2][2]));

        rgb[1] = ((aG * masc[0][0]) + (bG * masc[0][1]) + (cG * masc[0][2]) +
                (dG * masc[1][0]) + (eG * masc[1][1]) + (fG * masc[1][2]) +
                (gG * masc[2][0]) + (hG * masc[2][1]) + (iG * masc[2][2]));

        rgb[2] = ((aB * masc[0][0]) + (bB * masc[0][1]) + (cB * masc[0][2]) +
                (dB * masc[1][0]) + (eB * masc[1][1]) + (fB * masc[1][2]) +
                (gB * masc[2][0]) + (hB * masc[2][1]) + (iB * masc[2][2]));

        // return the value for all channel
        return (rgb);

    }
593069
function main() {
	var len;
	var min;
	var max;
	var f;
	var i;

	min = 1; // 10^min
	max = 6; // 10^max

	for ( i = min; i <= max; i++ ) {
		len = pow( 10, i );
		f = createBenchmark( len );
		bench( pkg+':len='+len, f );
	}
}
454254
function callProcessor(eventType, data, callback) {
    var p = processors[eventType];
    // no processors
    if (p===undefined || p.length==0) {
      if (callback!==undefined) callback(data);
      return;
    }
    // now go through all processors
    var n = 0;
    var cbCalled = false;
    var cb = function(inData) {
      if (cbCalled) throw new Error("Internal error in "+eventType+" processor. Callback is called TWICE.");
      cbCalled = true;
      if (n < p.length) {
        cbCalled = false;
        p[n++](inData, cb);
      } else {
        if (callback!==undefined) callback(inData);
      }
    };
    cb(data);
  }
751797
function xor_64_2(a, b)
	{
		return new Int_64(
			a.highOrder ^ b.highOrder,
			a.lowOrder ^ b.lowOrder
		);
	}
67797
def calculate_usage(self, cpu, total, busy):
        
        diff_total = total - self.prev_total[cpu]
        diff_busy = busy - self.prev_busy[cpu]

        self.prev_total[cpu] = total
        self.prev_busy[cpu] = busy

        if diff_total == 0:
            return 0
        else:
            return int(diff_busy / diff_total * 100)
512982
def shift_by_n_processors(self, x, mesh_axis, offset, wrap):
    
    n = self.shape[mesh_axis].size
    source_pcoord = []
    for i in xrange(n):
      c = i - offset
      if c != c % n:
        if wrap:
          c = c % n
        else:
          c = None
      source_pcoord.append(c)
    return self.receive(x, mesh_axis, source_pcoord)
177574
private static int nextPowerOfTwo(int v) {
        assert v >= 0;
        v--;
        v |= v >> 1;
        v |= v >> 2;
        v |= v >> 4;
        v |= v >> 8;
        v |= v >> 16;
        v++;
        return v;
    }
844480
function _gpfPow2 (n) {
    var result = _gpfPow2[n];
    if (result) {
        return result;
    }
    result = _gpfComputePow2(n);
    _gpfPow2[n] = result;
    return result;
}