Git Product home page Git Product logo

primery's Introduction

Primery

Primery is used to generate prime numbers in a specified range [x, y]. It also measures the time each algorithm needs to generate the prime numbers. It`s planned to expand the usage for checking primes as well and perfoming other operations.

license version

Supported algorithms

Algorithm Complexity
Trial Division O(n*sqrt(n))
Sieve of Eratosthenes O(n*log(log(n)))
Sieve of Sundaram O(n*log(n))
Sieve of Atkin O(n))

Time comparisons

Hardware:

CPU: 11th Gen Intel© Core™ i7-11800H @ 2.30GHz × 8
GPU: Intel Corporation TigerLake-H GT1 [UHD Graphics]

Single threaded:

n Sieve of Eratosthenes Sieve of Sundaram Sieve of Atkin
10⁵ 0.718 ms 0.602 ms 0.936 ms
10⁶ 7.544 ms 6.956 ms 8.386 ms
10⁷ 66.149 ms 65.015 ms 62.988 ms
10⁸ 0.947 s 1.007 s 0.837 s
10⁹ 10.956 s 16.559 s 8.839 s

Mulit threaded:

n Sieve of Eratosthenes Sieve of Sundaram Sieve of Atkin
10⁵ 3.197 ms 27.105 ms 10.941 ms
10⁶ 11.735 ms 140.159 ms 40.063 ms
10⁷ 62.772 ms 1.195 s 122.007 ms
10⁸ 0.49 s 11.984 s 0.511 s
10⁹ 7.284 s - 3.903 s

Conclusion:

Based on the data in the tables, it appears that the Sieve of Atkin is the fastest algorithm for generating prime numbers in both single-threaded and multi-threaded environments. In single-threaded mode, it is faster than the other two algorithms for all values of n tested. In multi-threaded mode, it is still the fastest algorithm for n up to 10⁸, and is competitive with the Sieve of Eratosthenes for n = 10⁹. The Sieve of Sundaram is slower than the other two algorithms in both single-threaded and multi-threaded mode. For large inputs, multithreading gives a great perfomance boost for generating prime numbers.

Makefile

#### primery v1.2 ####

Available targets:

build                          Build software
clean                          Remove program and output files
help                           Get help for Makefile
install                        Install software globally
uninstall                      Uninstall software

Usage

USAGE: primery [Options] {algorithm}

EXAMPLE: primery -i [234,100000] -t ms -m p sieveOfEratosthenes

SUPPORTED ALGORITHMS:
    { td  | trialDivision }
    { soe | sieveOfEratosthenes }
    { sos | sieveOfSundaram }
    { soa | sieveOfAtkin }

OPTIONS:
    -h, --help: Get help for the program
    -o, --output: Specify an output file for the generated prime numbers (default is primes.txt)
    -m, --mode: Specify a mode for generating prime numbers [s | single, p | parallel] (default is single)
    -t, --time: Specify time format [ns | nanoseconds, ms | milliseconds, s | seconds] (default is milliseconds)
    -i, --interval: Specify interval to generate prime numbers in format [start,end] (default is [2,1000])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.