{"size": 2059, "ext": "scrbl", "max_stars_repo_path": "pmap.scrbl", "max_stars_repo_name": "jsmaniac/pmap", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "pmap.scrbl", "max_issues_repo_name": "jsmaniac/pmap", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "pmap.scrbl", "max_forks_repo_name": "jsmaniac/pmap", "max_forks_repo_forks_event_min_datetime": "2021-10-02T16:19:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-02T16:19:43.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 28.2054794521, "max_line_length": 130, "alphanum_fraction": 0.6901408451}
#lang scribble/manual


@require[@for-label[pmap
                    racket/base
                    racket/future
                    racket/place
                    ]]

@title{pmap}
@author{APOS80}

@defmodule[pmap]

@section{pmapf}

pmapf works as map but applies the function to every item in the list/lists in parallel using futures.
It's restrictions is the same as for futures and map in general in Racket.


@racketblock[
    ;Example:
             
   >(pmapf + '(1 2 3) '(1 2 3))
   >'(2 4 6)
 ]

If the function applied is to simple pmap might perform worse than map because of the
overhead a future generate.


@section{pmapp}

pmapp works almost as map and applies the function to every item in the list/lists in parallel using places.
Places has some restrictions and that impacts on the implementation in several ways, READ ON!

First:
On creation of a place a rkt file is loaded into the new place, that means the uses of the place
is determined of the file and cant be changed by anyone else then the creator. For now it includes racket base, flonum and fixnum.

Second:
A procedure can NOT be passed to a place! Then how do you pass a function, as a list!

pmapp shows it strength in heavyer calcullations like mandelbrot, see the comparison section!

@racketblock[
    ;Example:
             
   >(pmapp '(lambda (x y)(+ x y) ) '(1 2 3) '(1 2 3))
   >'(2 4 6)

   >(pmapp '(lambda (x y)(fl+ x y) ) '(1.0 2.0 3.0) '(1.0 2.0 3.0))
   >'(2.0 4.0 6.0)
 ]

The place file has racket/base, racket/fixnum and math required.

@section{Comparison}

An comparison calcullating two mandelbrot's:
@racketblock[
 "(10000001 10000001) (4976.39990234375 ms)" ;map
 "(10000001 10000001) (4196.400146484375 ms)";pmapf
 "(10000001 10000001) (1840.7998046875 ms)"  ;pmapp
]

An comparison calcullating four mandelbrot's, with flonum:
@racketblock[
 "(10000001 10000001 10000001 10000001) (9752.256591796875 ms)";map
 "(10000001 10000001 10000001 10000001) (8613.47607421875 ms)" ;pmapf
 "(10000001 10000001 10000001 10000001) (1887.66064453125 ms)" ;pmapp
]
