Skip to content

A CLI tool for repeating a string an excessive number of times.

License

Notifications You must be signed in to change notification settings

hulloitskai/dgen

Repository files navigation

dgen

A CLI tool for repeating a string an excessive number of times.

Github Release Go Report Card Travis: Build Codecov: Coverage

Also check out begone, a fully automatic spamming tool for Facebook Messenger.

Installation

If you're on macOS, you can get dgen on Homebrew:

brew install stevenxie/tap/dgen

Otherwise, check out the latest compiled release!

Making from source

To install from source, make sure you have Go installed, and run:

## Clone the repository.
$ git clone git@github.com:stevenxie/dgen
$ cd dgen

## Install dependencies, and then install to $GOBIN.
$ make dl       # (or go mod download)
$ make install  # (or go install)

Usage

To repeat "test string" 50 times, simply perform the following command:

dgen "test string " 50
# Output: test string test string (...)

For more advanced usage options, view the help prompt with:

dgen --help

Presets

dgen comes with several presets in order to make your life easier. Each preset represents the character limit on the associated messaging service:

dgen "👀 " fb
# Output: 👀 👀 👀 👀 👀 👀 👀 👀 👀 (... x5000)

List of current dgen presets:

Name / ID Value Service
fb 5000 Facebook Messenger
twitter 280 Twitter
rpost 40,000 Reddit (post)
rcomment 10,000 Reddit (comment)
rmsg 10,000 Reddit (message)

Performance

dgen is one of the top-of-the-line string generators out there. dgen v1.0.1 sports the following benchmark:

  • Input: "benchmark test text "
  • Repetitions: 1,000,000
  • Duration: 25.050 seconds
  • Milliseconds / operation: 0.025039
  • Bytes allocated / operation: 21
  • Allocations / operation: 0

Integration

dgen is a thin wrapper around an internal library, throughput, which contains the actual repeating and buffering logic. To create a program with dgen's string dumping capabilities, simply import throughput:

package main

import (
  "github.com/stevenxie/dgen/throughput"
  "os"
)


func main() {
  var (
    repstr  = "test string "
    reps    = 5000
    bufsize = throughput.RecommendedBufSize
  )

  // Dump "test string " 5000 times into os.Stdout.
  throughput.Dump(repstr, reps, bufsize, os.Stdout)
}

Development

If you want to help develop dgen, clone the repository and run make setup to configure your development environment.