printf("write %d bytes, time = %dms\n", total,
printf("wrote %d bytes, time = %dms\n", total,
TestPipe(nsIInputStream* in, nsIOutputStream* out){    nsresult rv;    nsIThread* thread;    nsReceiver* receiver = new nsReceiver(in);    if (receiver == nsnull) return NS_ERROR_OUT_OF_MEMORY;    NS_ADDREF(receiver);    rv = NS_NewThread(&thread, receiver);    if (NS_FAILED(rv)) return rv;    PRUint32 total = 0;    PRIntervalTime start = PR_IntervalNow();    for (PRUint32 i = 0; i < ITERATIONS; i++) {        PRUint32 writeCount;        char* buf = PR_smprintf("%d %s", i, kTestPattern);        rv = out->Write(buf, nsCRT::strlen(buf), &writeCount);        if (gTrace) {            printf("wrote: ");            for (PRUint32 j = 0; j < writeCount; j++) {                putc(buf[j], stdout);            }            printf("\n");        }        PR_smprintf_free(buf);        if (NS_FAILED(rv)) return rv;        total += writeCount;    }    rv = out->Close();    if (NS_FAILED(rv)) return rv;    PRIntervalTime end = PR_IntervalNow();    thread->Join();    printf("write %d bytes, time = %dms\n", total,           PR_IntervalToMilliseconds(end - start));    NS_ASSERTION(receiver->GetBytesRead() == total, "didn't read everything");    NS_RELEASE(thread);    NS_RELEASE(receiver);    return NS_OK;}