定制 phpexperts/combinatorics 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpexperts/combinatorics

Composer 安装命令:

composer require phpexperts/combinatorics

包简介

A collection of utility classes for dealing with combinations.

README 文档

README

TravisCI Maintainability Test Coverage

Combinatorics is a PHP Experts, Inc., Project meant for the ease of access of Combinatorics algorithms.

See https://en.wikipedia.org/wiki/Combinatorics

Memory Consumption

Storing thousands of possibilities can be extremely memory intensive.

However, this project utilizes PHP Generators and uses only a few kilobytes to calculate and output millions of potential combinations (See the Benchmarks section below).

Generating All Possible Combinations

What are all the possibilities of A, B, C and D? More than you might think! 64. Add two more letters and you've got 1,956 possibilities.

How many different parking spot orderings can 8 cars occupy on any given day? Find out in the Usage section below!

Installation

Via Composer

composer require phpexperts/combinatorics

Usage

$generator = new CombinationsGenerator();

foreach ($generator->generate($styles) as $combination) {
    // If you can do what you need to do with the combinations here, without immediately storing
    // them into an array, then your memory usage will never exceed the amount needed store one 
    // combination.
}

You can see real-world usage of this project in the test suite of the Console Painter project](https://github.com/PHPExpertsInc/ConsolePainter).

Use cases

Testing

phpunit --testdox

To actually see what's going on -and- run the stress tests, run

phpunit --debug

Note: It takes over 5 minutes on an Intel i7 to run all of the stress tests.

Benchmarks

Level 1: Generating combinations for A
[
  Number of possibilities => 2
  Time (ms)               => 0.051975250244141
  Time (s)                => 5.1975250244141E-5
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 2: Generating combinations for A, B
[
  Number of possibilities => 4
  Time (ms)               => 0.047922134399414
  Time (s)                => 4.7922134399414E-5
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 3: Generating combinations for A, B, C
[
  Number of possibilities => 15
  Time (ms)               => 0.22578239440918
  Time (s)                => 0.00022578239440918
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 4: Generating combinations for A, B, C, D
[
  Number of possibilities => 64
  Time (ms)               => 1.0910034179688
  Time (s)                => 0.0010910034179688
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 5: Generating combinations for A, B, C, D, E
[
  Number of possibilities => 325
  Time (ms)               => 6.5748691558838
  Time (s)                => 0.0065748691558838
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 6: Generating combinations for A, B, C, D, E, F
[
  Number of possibilities => 1956
  Time (ms)               => 47.721147537231
  Time (s)                => 0.047721147537231
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 7: Generating combinations for A, B, C, D, E, F, G
[
  Number of possibilities => 13699
  Time (ms)               => 395.29585838318
  Time (s)                => 0.39529585838318
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 8: Generating combinations for A, B, C, D, E, F, G, H
[
  Number of possibilities => 109600
  Time (ms)               => 3834.4430923462
  Time (s)                => 3.8344430923462
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]
Level 9: Generating combinations for A, B, C, D, E, F, G, H, I
[
  Number of possibilities => 986409
  Time (ms)               => 37884.353876114
  Time (s)                => 37.884353876114
  Memory consumed         => 320
  Peak Memory (Diff)      => 0
]
Level 10: Generating combinations for A, B, C, D, E, F, G, H, I, J
[
  Number of possibilities => 9864100
  Time (ms)               => 422606.03785515
  Time (s)                => 422.60603785515
  Memory consumed         => 0
  Peak Memory (Diff)      => 0
]

Contributors

Theodore R. Smith theodore@phpexperts.pro
GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO: PHP Experts, Inc.

{ "transactionId" : "$transactionId", "crmId" : "$crmId", "zAccountId" : "$zuoraAccountId", "facilityId" : "$facilityId", "promo_code" : "$promo_code", "transactionTotal" : "$total_cost_for_facebook", "transactionProducts" : [$transactionProducts], "transactionAffiliation" : "U.S. LawShield" }

License

MIT license. Please see the license file for more information.

phpexperts/combinatorics 适用场景与选型建议

phpexperts/combinatorics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 188 次下载、GitHub Stars 达 9, 最近一次更新时间为 2019 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「combinatorics」 「combinations」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 phpexperts/combinatorics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 phpexperts/combinatorics 我们能提供哪些服务?
定制开发 / 二次开发

基于 phpexperts/combinatorics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 188
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 11
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-15