Beispiel #1
0
<?php

define('L', 10000000);
$tini = microtime(true);
function proc($ini, $fim)
{
    $acc = 0;
    $i = $ini;
    while ($i <= $fim) {
        $acc += $i++;
    }
    return $acc;
}
$r1 = proc(0, 2 * L);
$tfim = microtime(true);
$t1 = $tfim - $tini;
printf("Time elapsed single-thread version php: %.f \n", $t1);
printf("Result: %d\n", $r1);
Beispiel #2
0
set_include_path($cfg->zfPath);
require_once 'Zend/Feed/Writer/Feed.php';
$feed = new Zend_Feed_Writer_Feed();
$feed->setTitle($repoName . ' commit log - ' . $branch);
$feed->setDescription($repoDesc);
$feed->setLink($cfg->viewGitUri);
$feed->setFeedLink(($_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $cfg->type);
$feed->addAuthor(array('name' => $cfg->authorName, 'email' => $cfg->authorEmail));
// We'll set the feed's modification date to the date of the most recent commit.
$timeModified = 0;
// Loop over the last N commits.
foreach (proc("{$cfg->git} --git-dir={$repoPath} log {$branch} -{$cfg->numEntries} --format=format:'%H|%ct|%an|%ae|%s'") as $log) {
    list($commitId, $commitTime, $authorName, $authorEmail, $comment) = explode('|', $log, 5);
    // If this is the most recent commit, we'll use it for the feed's modification date.
    if ($commitTime > $timeModified) {
        $timeModified = $commitTime;
    }
    // We'll use the commit diff as the content.
    $diff = '<pre>' . htmlentities(proc("{$cfg->git} --git-dir={$repoPath} show --format={$cfg->format} {$commitId}", false)) . '</pre>';
    // Build the entry for this commit.
    $entry = $feed->createEntry();
    $entry->setTitle($authorName . ' : ' . $comment);
    $entry->setDescription($comment);
    $entry->setLink($cfg->viewGitUri . '?a=commitdiff&p=' . urlencode($repoName) . '&h=' . $commitId);
    $entry->addAuthor(array('name' => $authorName, 'email' => $authorEmail));
    $entry->setContent($diff);
    $entry->setDateModified($commitTime);
    $feed->addEntry($entry);
}
$feed->setDateModified($timeModified);
echo $feed->export($cfg->type);
<?php 
function proc($key, $val)
{
    incCounter("Users", "Total");
    if (empty($val['pages'])) {
        return;
    }
    incCounter("Users", "NumPages", count($val['pages']));
    foreach ($val['pages'] as $page_id => $val) {
        emit($page_id, 1);
    }
}
function incCounter($group, $counter, $inc = 1)
{
    fwrite(STDERR, "reporter:counter:" . $group . "," . $counter . "," . $inc . "\n");
}
function emit($key, $val)
{
    echo $key . "\t" . $val . "\n";
}
while (true) {
    $line = trim(fgets(STDIN));
    $parts = explode("\t", $line);
    if (count($parts) < 2) {
        fwrite(STDERR, "issue with input: " . $line);
    } else {
        proc($parts[0], json_decode($parts[1], true));
    }
    echo "|next|\n";
}
#!/usr/bin/php

<?php 
function proc($key, $vals)
{
    $sum = 0;
    foreach ($vals as $val) {
        $sum += intval($val);
    }
    emit($page_id, $sum);
}
function emit($key, $val)
{
    echo $key . "\t" . $val . "\n";
}
while (true) {
    $line = trim(fgets(STDIN));
    $parts = explode("\t", $line);
    proc($parts[0], explode(",", $parts[1]));
    echo "|next|\n";
}
Beispiel #5
0
         $msg = $_SESSION['shortUrls'][$myInfo]['msg'];
         $checknum = $_SESSION['shortUrls'][$myInfo]['checknum'];
         $_GET['msg'] = $msg;
         $_REQUEST['msg'] = $msg;
         $_GET['checknum'] = $checknum;
         $_REQUEST['checknum'] = $checknum;
     }
 }
 /*
  * [START] URL LOGIN
  * Copyright © 2012 Lars Knickrehm
  *
  * index.php?username=&password=&language=[auto]
  */
 if (isset($_REQUEST['username']) === true && isset($_REQUEST['password']) === true) {
     if (!proc('findPidByName', array('eyeDesk'))) {
         $_SESSION['username'] = $_REQUEST['username'];
         $_SESSION['password'] = $_REQUEST['password'];
         if (isset($_REQUEST['language']) === true) {
             $_SESSION['language'] = $_REQUEST['language'];
         } else {
             $_SESSION['language'] = '[auto]';
         }
     }
     $protocol = substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'));
     // utf8
     $location = strtolower($protocol) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
     header('Location: ' . $location);
     exit;
 }
 /*
Beispiel #6
0
function pro($s, $lv)
{
    if ($lv == count($GLOBALS['sep_array'])) {
        return proc($s);
    }
    if ($_POST['sep_pcre'] == 'on') {
        $a = preg_explode($GLOBALS['sep_array'][$lv], $s);
        $step = 2;
    } else {
        $a = explod($GLOBALS['sep_array'][$lv], $s);
        $step = 1;
    }
    $ct = 0;
    $x = count($a);
    for ($i = 0; $i < $x; $i += $step) {
        if (in_opt_range($ct, $lv, $x)) {
            $a[$i] = pro($a[$i], $lv + 1);
        }
        ++$ct;
    }
    if ($_POST['sep_pcre'] == 'on') {
        $s = implode('', $a);
    } else {
        $s = implode($GLOBALS['sep_array'][$lv], $a);
    }
    return $s;
}