Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

9
New Beta API vs Current API Benchmark
Post Body

Here's an exciting benchmark.

The goal is to simply collect the previous 50,000 comments from the AskReddit subreddit in batches of 5,000.

Here's how the current API performed:

Collected 50,000 comments in 53.79 seconds. (929 comments per second)

And here's how the new API performs:

Collected 50,000 comments in 10.0 seconds. (5,000 comments per second)

You can try out the new dev API with this script:

#!/usr/bin/env python3

import requests
import ujson as json
import time
from collections import defaultdict
from lru import LRU #pip3 install lru-dict


def query_es(t=None,subreddit=None):

    q = defaultdict(dict)
    headers = {'Content-Type':'application/json'}
    q['query']['bool'] = {}
    q['query']['bool']['must'] = m = []
    q['sort'] = {'created_utc':'desc'}
    q['size'] = batch_size
    m.append({'match':{'subreddit':subreddit}})
    m.append({'range':{'created_utc':{'lte':t}}})
    r = requests.get("http://dev.pushshift.io/rc/_search",headers=headers,data=json.dumps(q))
return r.json()


created_utc = None
batch_size = 5000
seen_ids = LRU(batch_size * 2)
count = 0
start_time = time.time()
subreddit = "askreddit"
cutoff = 50000

while True:

    data = query_es(created_utc,subreddit)
    c_flag = False

    for d in data['hits']['hits']:
        id = int(d['_id'])
        d = d['_source']
        if id in seen_ids:
            continue
        count  = 1
        c_flag = True
        seen_ids[id] = True
        created_utc = d['created_utc']
        if count == cutoff:
            c_flag = False
            break


    if not c_flag:
        break

    print("Got {} {} comments. Current position: {}".format(count,subreddit,time.strftime("%Z - %Y/%m/%d, %H:%M:%S", time.localtime(created_utc))))

end_time = time.time() - start_time

print("Collected {:,} comments from {} in {:,} seconds. ({:,} comments per second)".format(count,subreddit,round(end_time,2),int(count/end_time)))

Author
Account Strength
100%
Account Age
11 years
Verified Email
No
Verified Flair
No
Total Karma
143,730
Link Karma
34,810
Comment Karma
108,242
Profile updated: 2 days ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago