Skip to content

Instantly share code, notes, and snippets.

View AaronSchulz's full-sized avatar

Aaron AaronSchulz

  • Wikimedia Foundation
  • San Francisco, CA
View GitHub Profile
@AaronSchulz
AaronSchulz / ab_example.sh
Last active September 29, 2026 18:11
Run apcu test operations in PHP
#!/bin/sh
# Within 10 concurrent requests, do 1 round of get and set operations to the same collection of 100 keys with 1MB values
ab -n 10 -c 10 'http://localhost/core/apcu_rw.php?keysCount=100&minSize=1000000&maxSize=1000000&iterations=10&mode=gas'
# In one request, do a get and set operation to a collection of 100 keys with 1MB values, with profiling to /tmp/apcu_trace.log.
# This can be run in another terminal while huge -n command similar to above runs in order to profile apcu under pressure.
ab -n 1 -c 1 'http://localhost/core/apcu_rw.php?keysCount=100&minSize=1000000&maxSize=1000000&iterations=10&mode=gas&profile=1'
# Drag/drop /tmp/apcu_trace.log (assumping php-excimer is installed) into https://www.speedscope.app/
@AaronSchulz
AaronSchulz / wiki_login
Created November 22, 2023 18:45
Example script for getting MediaWiki login session cookies via password login and using them with api.php/rest.php
#!/bin/bash
SITE_URL=$1
USER_NAME=$2
COOKIE_PREFIX=$3
if [[ -z "$SITE_URL" || -z "$USER_NAME" || -z "$COOKIE_PREFIX" ]]; then
echo "wiki_login <api.php url> <username> <site cookie prefix>"
echo "e.g. wiki_login https://localhost/core aaron my_wiki"
exit 1
fi
#!/bin/bash
echo memcached-php
echo =============
sudo -u www-data php tests/phpunit/phpunit.php tests/phpunit/includes/libs/objectcache/BagOStuffTest.php --use-bagostuff=memcached-php
echo memcached-pecl
echo =============
sudo -u www-data php tests/phpunit/phpunit.php tests/phpunit/includes/libs/objectcache/BagOStuffTest.php --use-bagostuff=memcached-pecl
echo hash
echo =============
sudo -u www-data php tests/phpunit/phpunit.php tests/phpunit/includes/libs/objectcache/BagOStuffTest.php --use-bagostuff=hash